Missing operation for soapAction and body element
来源:互联网 发布:淘宝店铺联盟怎么开通 编辑:程序博客网 时间:2024/06/02 05:46
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]
初看这个问题比较头痛,这是个底层报错,Axis2自动组装的消息无法被解析,首先需要做的就是观察消息是格式
<?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模拟服务端口(客户端最好重新生成)
0 0
- Missing operation for soapAction and body element
- XmlTextReader and XmlException: Root element is missing
- Realm for android Basic configuration and operation
- SOAP Body Element
- The SOAP Body Element
- Expected selector for Objective-C and Expected method body
- Root element is missing
- leetcode-first missing element
- bsxfun matlab element-by-element operation
- 3D Modeling and Animation: Synthesis and Analysis Techniques for the Human Body
- The Linux Page Cache and pdflush:Theory of Operation and Tuning for Write-Heavy Loads
- org.apache.cxf.interceptor.Fault: The given SOAPAction ... does not match an operation
- org.apache.cxf.interceptor.Fault: The given SOAPAction ... does not match an operation
- MySQL: Root element is missing
- get方法Required request body is missing
- Required request body is missing 错误解决
- Xcode报错Expected selector for Objective-C and Expected method body
- Xcode报错Expected selector for Objective-C and Expected method body
- MSVC与CRT默认库链接冲突问题
- typedef使用详解
- ireport使用中遇到的问题及解决方法
- 迭代法实现归并排序
- 演化策略和遗传算法的区别
- Missing operation for soapAction and body element
- 用户控件提示没有指定HtmlGenericControl的ID属性是什么错误
- hdu-1257
- 购房首付的和奋斗史
- ioctl 变成了 unlocked_ioctl
- 1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strncmp 已经在 libcmtd.lib(strncmp.obj) 中定义
- MFC透明位图(2)--PNG的实现
- LeetCode: Minimum Window Substring
- Linux/Unix下pid文件作用浅析