如何通过Axis服务部署项目

(1)首先写wsdl文件 EditShoppingCartService.wsdl和执行属性文件 EditShoppingCartService.xsd,具体写法请参考基于AXIS2实现Web Service开发.doc

(2)通过wsdl生成Java代码,执行 Wsdl2Java.class, 参数为
-ss -ssi -sd -uri  wsdl/EditShoppingCartService.wsdl, 该代码为服务端代码

(3)把生成的代码通过 Axis2 Service Archiver打成aar包,或者打成jar包,然后改名字

(4)把 EditShoppingCartService.xsd手动加入到aar的/META-INFO/下面

(5)把axis2.war发布到tomcat上面,打开tomcat,输入 http://localhost:8080/axis2/,然后上传到axis2的系统上面

(6)生成客户端代码,执行Wsdl2Java.class, 参数为
-a  -s -p demo.test.client.adb  -uri wsdl/EditShoppingCartService.wsdl

(7)编写客户端测试类(同步)
EditShoppingCartServiceStub stub = new EditShoppingCartServiceStub();
QueryShoppingCartByCustomer req = new QueryShoppingCartByCustomer();
BookListType list =new BookListType();
BookType type = new BookType();
//放值到实体对象
//……
list.setBook(types);
//req为发送实体到服务端
req.setQueryShoppingCartByCustomer(list);
QueryShoppingCartByCustomerResponse res = stub.queryShoppingCartByCustomer(req);
//res为返回对象
//这个对象为返回的实体对象
res.getQueryShoppingCartByCustomerResponse()

(8)编写客户端测试类(异步)
EditShoppingCartServiceStub stub = new EditShoppingCartServiceStub();
QueryShoppingCartByCustomer req = new QueryShoppingCartByCustomer();
BookListType list =new BookListType();
BookType type = new BookType();
//放值到实体对象
//……
list.setBook(types);
//req为发送实体到服务端
req.setQueryShoppingCartByCustomer(list);
EditShoppingCartServiceCallbackHandler callback = new EditShoppingCartServiceCallbackHandler() {
  public void receiveResultqueryShoppingCartByCustomer(
    QueryShoppingCartByCustomerResponse result) {
    System.out.println(result.getQueryShoppingCartByCustomerResponse().getResMessage());
  }
  public void receiveErrorqueryShoppingCartByCustomer(
    java.lang.Exception e) {
  }
};
stub.startqueryShoppingCartByCustomer(req, callback);
System.out.println("send Request!!");

你可能感兴趣的:(axis)