import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
public class CXFClient {
public CXFClient(){}
public Object[] sendSoap(String wsdlUrl,String hostMethod,Object...params) throws Exception{
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Object[] objects = dcf.createClient(wsdlUrl).invoke(hostMethod, params);
return objects;
}
}
public class CXFClient {
public CXFClient(){}
public Object[] sendSoap(String wsdlUrl,String hostMethod,Object...params) throws Exception{
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Object[] objects = dcf.createClient(wsdlUrl).invoke(hostMethod, params);
return objects;
}
}
调用方法:
cXFClient.sendSoap(wsdlUrl, methodName, param1,param2,...);
cxf需要的包:
cxf-core-3.0.1.jar
cxf-rt-bindings-soap-3.0.1.jar
cxf-rt-databinding-jaxb-3.0.1.jar
cxf-rt-frontend-jaxws-3.0.1.jar
cxf-rt-frontend-simple-3.0.1.jar
cxf-rt-transports-http-3.0.1.jar
cxf-rt-wsdl-3.0.1.jar
stax2-api-3.1.4.jar
woodstox-core-asl-4.4.0.jar
wsdl4j-1.6.3.jar
xmlschema-core-2.1.0.jar