论坛首页 Java企业应用论坛

CXF动态客户端No operation was found with the name问题

浏览 8333 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2014-01-06  
如果WebService发布时,接口和实现类指定的namespace不同。

那么使用CXF动态客户端调用时,会抛出No operation was found with the name的异常。

JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdl);
Object[] res = client.invoke(operation, realParams);


用下面的方法临时处理一下吧:
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdl);

// 下面一段处理 WebService接口和实现类namespace不同的情况
// CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
Endpoint endpoint = client.getEndpoint();
QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operation);
BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
if (bindingInfo.getOperation(opName) == null) {
	for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
		if (operation.equals(operationInfo.getName().getLocalPart())) {
			opName = operationInfo.getName();
			break;
		}
	}
}

Object[] res = client.invoke(opName, realParams);
   发表时间:2014-05-26  
你好,怎么样才能使QName的构造方法new QName(URI,oeration),满足new QName(operation,operation)也能正常访问呢?就是不用知道namespaceuri,只知道address和方法名、参数名就能访问

服务端应该如何配置才能实现呢?
0 请登录后投票
   发表时间:2014-06-06  
楼主这个方法确实有效!感谢!
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics