2、设置axis2的环境变量
3、把wsdl文件保存到本地 *.wsdl
4、通过dos命令生成客户端程序
C:\Users\kk>e:
E:\>cd E:\mysoft\axis2-1.7.3-bin\axis2-1.7.3\bin
E:\mysoft\axis2-1.7.3-bin\axis2-1.7.3\bin>wsdl2java -uri C:\Users\kk\Desktop\zws_product.wsdl -p com.kk.proj.service.product -o stub
(其中-uri参数指定了wsdl文件的路径,可以是本地路径,也可以是网络路径。-p参数指定了生成的Java类的包名,-o参数指定了生成的一系列文件保存的根目录。在执行完上面的命令后,读者就会发现在当前目录下多了个stub目录)
5、把stub目录下生成的java文件拷贝到程序中就可以使用了,可能会提示有些方法没有实现,你需要手动实现下,body里不需要写代码,保证不报错就行了
6、程序调用生成的代码请求webservice数据
ZWS_CUSTOMERStub stub = new ZWS_CUSTOMERStub();
HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
authenticator.setUsername("xx);
authenticator.setPassword("xx");
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE,authenticator);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,"GBK");
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.HTTP_METHOD,HTTPConstants.HTTP_METHOD_POST);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(5*60*1000);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,5*60*1000);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,5*60*1000);
ZWS_CUSTOMERStub.ZhySdFgCustomer in = new ZWS_CUSTOMERStub.ZhySdFgCustomer();
ZWS_CUSTOMERStub.ZhySdFgCustomerResponse out = stub.zhySdFgCustomer(in);
String result = out.getEvJson().toString();