WSDL配置SOAP 1.2时遇到向仅SOAP 1.1端点发消息无效错误
问题根因
你遇到的报错核心原因是服务端运行环境仅启用了SOAP 1.1的适配逻辑,未开启SOAP 1.2的支持配置,与你本地的报文构造、WSDL定义无关。
其中http://schemas.xmlsoap.org/soap/envelope/是SOAP 1.1的标准信封命名空间,http://www.w3.org/2003/05/soap-envelope是SOAP 1.2的标准信封命名空间,服务端识别到1.2版本的命名空间后,发现自身无对应处理逻辑,因此抛出版本不兼容报错。
配置解决方案
根据你服务端使用的技术栈,选择对应配置方式即可:
- Java技术栈
- Spring Boot + Spring WS场景:在WebService配置类中修改
DefaultWsdl11DefinitionBean配置,开启SOAP 1.2支持:@Bean public DefaultWsdl11Definition yourServiceWsdl(XsdSchema yourServiceSchema) { DefaultWsdl11Definition wsdlDefinition = new DefaultWsdl11Definition(); wsdlDefinition.setPortTypeName("YourServicePort"); wsdlDefinition.setLocationUri("/ws/your-service-path"); wsdlDefinition.setTargetNamespace("你的服务目标命名空间"); wsdlDefinition.setSchema(yourServiceSchema); // 同时开启SOAP1.1和SOAP1.2支持,仅需1.2可关闭1.1的开关 wsdlDefinition.setCreateSoap11Binding(true); wsdlDefinition.setCreateSoap12Binding(true); return wsdlDefinition; } - CXF场景:发布服务时显式指定bindingId为
SOAPBinding.SOAP12HTTP_BINDING,如需同时支持两个版本,配置两个不同路径的端点即可。 - Axis2场景:修改axis2.xml配置文件,开启SOAP 1.2的协议支持开关,确保传输接收器可处理1.2版本的报文。
- Spring Boot + Spring WS场景:在WebService配置类中修改
- .NET技术栈
- WCF场景:在配置文件中将绑定从仅支持SOAP1.1的
basicHttpBinding替换为支持SOAP1.2的配置,示例如下:<bindings> <customBinding> <binding name="SOAP12Binding"> <textMessageEncoding messageVersion="Soap12" /> <httpTransport /> </binding> </customBinding> </bindings> - ASP.NET ASMX服务场景:在web.config中添加SOAP1.2协议支持:
<configuration> <system.web> <webServices> <protocols> <add name="HttpSoap12"/> <add name="HttpSoap"/> </protocols> </webServices> </system.web> </configuration>
- WCF场景:在配置文件中将绑定从仅支持SOAP1.1的
配置后验证
配置完成后发请求测试前,需确认请求头的Content-Type符合SOAP 1.2要求:SOAP 1.2要求Content-Type为application/soap+xml,SOAP1.1要求为text/xml,头信息错误也会触发同类版本不兼容报错。
配置生效后,携带SOAP1.2命名空间的信封报文即可正常得到响应。
内容的提问来源于stack exchange,提问作者user15012700
相关产品推荐
相关产品推荐

