c# – 如何更改WCF中的SOAP Envelope架构?

前端之家收集整理的这篇文章主要介绍了c# – 如何更改WCF中的SOAP Envelope架构?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我通过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版本

原文链接:https://www.f2er.com/csharp/98464.html

猜你在找的C#相关文章