1.添加依赖
<dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-core</artifactId> </dependency>
2.代码
package test; import java.util.Arrays; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.junit.Test; public class CasWebserviceTest { @Test public void test() { try { JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory .newInstance(); Client client = dcf .createClient("http://101.103.117.8/ssows/WSAuth.asmx?wsdl"); for (int i = 0; i < 100; i++) { System.out.println(Arrays.toString(client.invoke("IsValidUser", new Object[] { "test", "test" }))); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }