使用cxf调用webservice
1、引入maven包
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf.version}</version> </dependency>
2、创建Client对象
public static Client getDynamicClient(String wsdlUrl) { if (client == null) { synchronized (this.class) { if (client == null) { DynamicClientFactory dcf = DynamicClientFactory.newInstance(); client = dcf.createClient(wsdlUrl); } } } return client; }