CXF WebService No operation was found with the name

Webservice 调用带用户名密码的接口 ,CXF中 the namespace on the "definitions" element, is not a valid SOAP version报错!:https://www.cnblogs.com/vipsoft/p/19135628
CXF WebService 授权&动态调用 : https://www.cnblogs.com/vipsoft/p/14994471.html

[2025-10-23 14:59:56.958] [http-nio-22586-exec-1] [ERROR] TO_HIS_API_LOGGER - No operation was found with the name {http://tempuri.org/}Run.
org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://tempuri.org/}Run.
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:325)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
        at com.iron.his.hospital.service.impl.MediinfoServiceImpl.regInfo(MediinfoServiceImpl.java:125)
        at com.iron.his.hospital.controller.ddyyController.regInfo(PzddyyController.java:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)

解决办法:

// CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
Endpoint endpoint = client.getEndpoint();
QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), "Run");
BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
if (bindingInfo.getOperation(opName) == null) {
    for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
        if ("Run".equals(operationInfo.getName().getLocalPart())) {
            opName = operationInfo.getName();
            break;
        }
    }
}

//Object[] objects = client.invoke("Run", "HL7v24", "ORM^O01", encode);
Object[] objects = client.invoke(opName, "HL7v24", "ORM^O01", encode);
posted @ 2025-10-23 15:05  VipSoft  阅读(4)  评论(0)    收藏  举报