java调用wsdl xfire和cxf两种方式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java调用wsdl xfire和cxf两种方式相关的知识,希望对你有一定的参考价值。
xfire 如下:
String spID = ""; String password = ""; String accessCode = ""; String content = ""; String mobileString = ""; String url = ""; String operateName = "Submit"; Object[] object = new Object[]{spID,password,accessCode,content,mobileString}; org.codehaus.xfire.client.Client client = new org.codehaus.xfire.client.Client(new URL(url)); String a = client.getUrl(); Object[] results = client.invoke(operateName, object); System.out.println("aaaa:" + results[0]);
cxf
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(url);
// 下面一段处理 WebService接口和实现类namespace不同的情况
// CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
Endpoint endpoint = client.getEndpoint();
QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operateName);
BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
if (bindingInfo.getOperation(opName) == null) {
for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
if (operateName.equals(operationInfo.getName().getLocalPart())) {
opName = operationInfo.getName();
break;
}
}
}
Object[] res = client.invoke(opName, object);
以上是关于java调用wsdl xfire和cxf两种方式的主要内容,如果未能解决你的问题,请参考以下文章