生成webservice客户端

1.使用JAVA自带的wsiport生成客户端


命令wsimport -s . xxxxxx.wsdl

2.生成客户端使用idea生成


右键需要生成的包,选择webservice-Generate Java Code From Wsdl……

生成webservice客户端_第1张图片
添加本地或者远程wsdl地址,点击ok生成

3.调用JAX客户端

 		HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(30000);
        httpClientPolicy.setReceiveTimeout(120000);
        HttpConduitConfig httpConduitConfig = new HttpConduitConfig();
        httpConduitConfig.setClientPolicy(httpClientPolicy);
        HttpConduitFeature httpConduitFeature = new HttpConduitFeature();
        httpConduitFeature.setConduitConfig(httpConduitConfig);
        //实例化实现类
        XxxAdapterService xxxAdapterService = new XxxAdapterService (httpConduitFeature);
        //获取接口方法
        XxxAdapterServiceInterface xxxAdapterServiceInterface = xxxAdapterServiceInterface .getXxxAdapterServicePort();

4.使用eclipse生成axis带用户名密码的客户端


右键点击New-Other
生成webservice客户端_第2张图片
选择Web Service Client
生成webservice客户端_第3张图片
生成webservice客户端_第4张图片
完成WebService客户端生成

4.使用eclipse生成axis带用户名密码的客户端

xxxServiceLocator locator = new xxxServiceLocator();
xxxAdapterServicePortBindingStub stub = (xxxAdapterServicePortBindingStub) locator.getXxxAdapterServicePortBindingQSPort();
stub.setUsername("用户名");
stub.setPassword("密码");
StringHolder _return = new StringHolder();
StringHolder returnStatus = new StringHolder();
StringHolder returnMsg = new StringHolder();        stub.xxxService(method,data,_return,returnStatus,returnMsg);

你可能感兴趣的:(web-servic,工作经验)