c# – 如何更改WCF中的SOAP Envelope架构?
发布时间:2020-12-15 18:25:02 所属栏目:百科 来源:网络整理
导读:我通过WCF连接到第三方端点,我有一个问题. WCF生成的SOAP信封的模式与端点不兼容. 目前WCF正在生成: s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" 但它必须是这样的: s:Envelope xmlns:
我通过WCF连接到第三方端点,我有一个问题. WCF生成的SOAP信封的模式与端点不兼容.
目前WCF正在生成: <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> 但它必须是这样的: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"> 我在soapUI中对此进行了测试以确认这是问题,但我如何在WCF中控制它?我使用Visual Studio中的“添加服务引用”选项来生成服务. 有任何想法吗? 提前致谢. 安迪 解决方法
最有可能的是,SOAP版本存在问题.你用什么装订?
basicHttpBinding默认为SOAP 1.1,而wsHttpBinding默认为SOAP 1.2 这是SOAP 1.1(basicHttpBinding中的默认值): <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 虽然这是SOAP 1.2(在wsHttpBinding中默认): <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> 可能的解决方案: 1)要么你只能切换绑定,那就是所有 – 你需要确保检查安全设置等等(基本和wsHttpBinding之间有所不同) 要么 2)您需要创建自己的自定义绑定并明确指定所需的SOAP版本 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |