package cxfClient;
import ;
import ;
import ;
import ;
import ;
public class CxfClient {
public static void main(String[] args) throws Exception {
String url = "http://localhost:9091/Service/SayHello?wsdl";
String method = "say";
Object[] parameters = new Object[]{"我是参数"};
(invokeRemoteMethod(url, method, parameters)[0]);
}
public static Object[] invokeRemoteMethod(String url, String operation, Object[] parameters){
JaxWsDynamicClientFactory dcf = ();
if (!("wsdl")) {
url += "?wsdl";
}
client = (url);
//处理webService接口和实现类namespace不同的情况,CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
Endpoint endpoint = ();
QName opName = new QName(().getName().getNamespaceURI(),operation);
BindingInfo bindingInfo= ().getBinding();
if((opName) == null){
for(BindingOperationInfo operationInfo : ()){
if((().getLocalPart())){
opName = ();
break;
}
}
}
Object[] res = null;
try {
res = (opName, parameters);
} catch (Exception e) {
();
}
return res;
}
}