0.jar包
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>commons-logging</groupId>-->
<!-- <artifactId>commons-logging</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
</dependency>
<!-- <dependency>-->
<!-- <groupId>commons-logging</groupId>-->
<!-- <artifactId>commons-logging</artifactId>-->
<!-- <version>1.2</version>-->
<!-- </dependency>-->
注意:由于包commons-discovery与包commons-logging冲突,所以注释掉Spring中用到的commons-logging
1.打开idea的全局搜索(默认是双击shift键)
获取接口实例及调用方法的代码如下:
JDKJService service = new JDKJServiceLocator();
JDKJServiceSoapBindingStub webService = (JDKJServiceSoapBindingStub) service.getServiceSoap();
几点说明:
1.接口的调用可以写个工具类,之后再调用时直接获取即可。
2.webService服务的地址在以Locator结尾的类中,如果需要动态获取此地址而不是写死在代码中,可以给规定此地址的变量价格set方法,之后在实例化完成时给此变量重新赋值。示例如下:
ItemDO itemDO = "比如数据库获取地址值";
JDKJServiceLocator service = new JDKJServiceLocator();
service.setServiceSoap_address(address);
service.setServiceSoap12_address(address);
JDKJServiceSoapBindingStub webService = (JDKJServiceSoapBindingStub) service.getServiceSoap();