WSO2使用Class Mediator处理SOAP消息时出现传输层信息不匹配错误
Transport level information does not match with SOAP Message namespace URI in WSO2 Class Mediator
Problem Description
在WSO2中接收SOAP消息后,尝试使用Class Mediator处理时触发以下错误:
Transport level information does not match with SOAP Message namespace URI
收到的SOAP请求内容如下:
<?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <prov> <rowID>2106480</rowID> <msisdn>745340612</msisdn> </prov> </soapenv:Body> </soapenv:Envelope>
Root Cause
这个错误的核心原因是SOAP消息版本与传输层HTTP头信息不匹配:
- 你提供的SOAP消息使用SOAP 1.2标准(命名空间
http://www.w3.org/2003/05/soap-envelope是SOAP 1.2的专属命名空间) - 如果请求的HTTP
Content-Type头是SOAP 1.1对应的text/xml,而非SOAP 1.2要求的application/soap+xml,WSO2消息处理引擎会判定传输层信息与SOAP消息命名空间不匹配,抛出该错误 - 若WSO2代理服务/API配置中强制指定了SOAP 1.1版本,而实际接收的是SOAP 1.2消息,也会触发版本冲突
Solutions
1. 修正HTTP请求的Content-Type头
要求发送方将请求头设置为SOAP 1.2对应格式:
Content-Type: application/soap+xml; charset=utf-8
2. 调整WSO2服务配置适配SOAP 1.2
若无法修改发送方配置,需在WSO2代理服务/API中明确支持SOAP 1.2:
- 在代理服务的
inSequence或endpoint节点中添加版本指定配置:
<property name="SOAP_VERSION" value="1.2" scope="axis2"/>
- 或在API定义中,将绑定类型设置为SOAP 1.2
3. 检查Class Mediator逻辑
确认自定义Class Mediator未错误修改SOAP信封的命名空间,或在处理过程中导致传输层信息与消息版本不一致,比如不要将SOAP Envelope的命名空间替换为SOAP 1.1的http://schemas.xmlsoap.org/soap/envelope/
内容的提问来源于stack exchange,提问作者Wajih Haider
相关产品推荐
相关产品推荐

