1、新建soap工程,输入wsdl,出现上图
可以是用adb,jibx,xmlbean等,要引入对应的包jar
2、根据上面的提示生成对应的java代码
代码引入太多,有点不优雅,
1、使用ant打包
涉及到ant下载,系统环境变量的配置,ant
2、pom引入
<dependency>
<groupId>com.ysk</groupId>
<artifactId>ysk</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/StarSystemWebService-test-client.jar</systemPath>
</dependency>
3、
String targetEndpoint = "http://xxx.com/AvconWebService/services/StandarMonitorService?wsdl";
MonitorServiceServiceStub serviceServiceStub = new MonitorServiceServiceStub(targetEndpoint);
HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
auth.setUsername("username");//用户名
auth.setPassword("password");//密码
auth.setPreemptiveAuthentication(true); //具体看SoapUI中的配置
serviceServiceStub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);
GetMonitorGroup groupDto = new GetMonitorGroup();
groupDto.setParentId("G2@zjyjj");
GetMonitorGroupResponse monitorGroup = serviceServiceStub.getMonitorGroup(groupDto);
System.out.println(JSON.toJSONString(monitorGroup));
调某康的接口报错。
org.apache.axis2.AxisFault: First Element must contain the local name, Envelope , but found Fault
解决方式:stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);