Missing operation for soapAction and body element
发布时间:2020-12-16 23:15:30 所属栏目:安全 来源:网络整理
导读:Axis2版本:1.6.2 SoapUI版本:5.0.0 ? 使用Eclipse的Axis2插件生成WebServic客户端后,使用同样的WSDL文件通过SoapUI模拟出的WebService服务端进行测试,测试过程中报错如下: org.apache.axis2.AxisFault: Missing operation for soapAction [urn:add] and
Axis2版本:1.6.2 SoapUI版本:5.0.0 ? 使用Eclipse的Axis2插件生成WebServic客户端后,使用同样的WSDL文件通过SoapUI模拟出的WebService服务端进行测试,测试过程中报错如下: org.apache.axis2.AxisFault: Missing operation for soapAction [urn:add] and body element [{http://sean}add] with SOAP Version [SOAP 1.2]
<?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:add xmlns:ns1="http://sean"> <ns1:args0>1</ns1:args0> <ns1:args1>2</ns1:args1> </ns1:add> </soapenv:Body> </soapenv:Envelope> 通过SoapUI,可以找到正确的消息格式 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sean="http://sean.com"> <soap:Header/> <soap:Body> <sean:add> <!--Optional:--> <sean:args0>?</sean:args0> <!--Optional:--> <sean:args1>?</sean:args1> </sean:add> </soap:Body> </soap:Envelope> 比较之后可以发现,两者之间的唯一区别就是命名空间不同,一个使用http://sean,而另一个使用http://sean.com 这时想到我手动修改了Axis2自动生成的请求封装类中的命名空间: public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( "http://sean","add","ns1"); 而在接口的WSDL文件中定义的命名空间为 <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://sean.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://sean.com"> ...... 可见客户端和服务端的命名空间对应不上,导致消息内容解析时出现异常 ? 修改方式分为2种 1,将代码中的命令空间改回http://sean.com 2,将WSDL文件中的命名空间修改为http://sean,并用新的WSDL文件创建新的SoapUI模拟服务端口(客户端最好重新生成) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |