package webservice; import javax.xml.namespace.QName; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; public class Test1 { public static void main(String[] args) throws Exception { JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("http://localhost:8080/myproject/webservice/test?wsdl"); Object[] returnObject = client.invoke("sayHello", "99999"); System.out.println(returnObject[0].toString()); } }
如果报错:com/sun/tools/internal/xjc/api/XJC的话,引入jdk8\lib/too.jar架包。