WSO2 Enterprise Integrator 6.5.0:如何阻止SOAP消息自动生成XML标签?
解决WSO2 EI中调用SOAP端点时自动重复生成XML标签的问题
你遇到的问题是因为WSO2默认会把消息内容当作SOAP Body的内容,自动为其包裹一层SOAP Envelope,但你已经通过PayloadFactory手动生成了完整的Envelope,导致出现重复标签引发端点异常。以下是可行的解决步骤:
添加
DISABLE_SOAP_ENVELOPE_BUILDER属性:在PayloadFactory之后、调用端点之前,添加这个属性,阻止WSO2自动构建SOAP Envelope:<property name="DISABLE_SOAP_ENVELOPE_BUILDER" scope="axis2" type="BOOLEAN" value="true"/>匹配SOAP版本的
messageType和endpointformat:- 若调用SOAP 1.1端点,
messageType设为text/xml,endpoint的format保持soap11 - 若调用SOAP 1.2端点,
messageType设为application/soap+xml,endpoint的format改为soap12
- 若调用SOAP 1.1端点,
可选:添加
FORCE_SC_ACCEPTED属性:部分场景下可通过该属性避免处理异常:<property name="FORCE_SC_ACCEPTED" scope="axis2" type="BOOLEAN" value="true"/>
修改后的完整代码片段
<payloadFactory media-type="xml"> <format> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.test.com/"> <soapenv:Header/> <soapenv:Body> <ws:process> <request> <action>$1</action> <transaction> <id>$2</id> </transaction> </request> </ws:process> </soapenv:Body> </soapenv:Envelope> </format> <args> <arg evaluator="xml" expression="get-property('ACTION')"/> <arg evaluator="xml" expression="get-property('TRANSACTION_ID')"/> </args> </payloadFactory> <!-- 阻止自动构建SOAP Envelope --> <property name="DISABLE_SOAP_ENVELOPE_BUILDER" scope="axis2" type="BOOLEAN" value="true"/> <!-- SOAP 1.1对应text/xml,SOAP1.2对应application/soap+xml --> <property name="messageType" scope="axis2" type="STRING" value="text/xml"/> <log level="full"/> <call-template target="do_call"/>
模板中的endpoint(SOAP1.1示例)
<call> <endpoint> <address format="soap11" uri="${uri.var.url}"/> </endpoint> </call>
原理说明
DISABLE_SOAP_ENVELOPE_BUILDER会禁用WSO2的SOAP Envelope构建器,让系统直接使用你手动生成的完整Envelope发送请求,避免重复包裹。同时确保messageType和endpoint的format与目标SOAP版本一致,保证请求格式符合端点要求。
内容的提问来源于stack exchange,提问作者user666
相关产品推荐
相关产品推荐

