CXF结合Spring发布一个webservice服务。
然后对方使用wsdl2java方式生成的客户端调用服务报错。does not match an operation 。
org.apache.axis2.AxisFault: The given SOAPAction http://xxx.xxx.xxx.com/xxx/xxx_Login does not match an operation. at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at client.UnionHsmManServiceStub.hsm_Login(UnionHsmManServiceStub.java:2058) at com.hgsoft.ws.client.HttpInvoker.stub(HttpInvoker.java:88) at com.hgsoft.ws.client.HttpInvoker.main(HttpInvoker.java:72)
是因为cxf发布的wsdl中,方法对应的soapAction不存在,需要再服务端接口定义的地方,注解的位置加上action的属性,如:
@WebMethod(action = "http://xxx.xxx.xxx.com/xxx/xxx_Login" ) public @WebResult(name="return")String Hsm_Login( @WebParam(name="UserKey")String UserKey, @WebParam(name="KeyPassword")String KeyPassword);
然后wsdl中就会生成这个定义
<wsdl:operation name="Hsm_Login"> <soap:operation soapAction="http://xxx.xxx.xxx.com/xxx/xxx_Login" style="rpc"/> <wsdl:input name="Hsm_Login"> <soap:body namespace="http://xxx.xxx.xxx.com/" use="literal"/> </wsdl:input> <wsdl:output name="Hsm_LoginResponse"> <soap:body namespace="http://xxx.xxx.xxx.com/" use="literal"/>
</wsdl:output> </wsdl:operation>
OK ,解决问题。