gpt4 book ai didi

c# - 如何更改 WCF 中的 SOAP 信封架构?

转载 作者:太空狗 更新时间:2023-10-29 18:07:55 25 4
gpt4 key购买 nike

我正在通过 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 版本很可能有问题。您使用的是什么绑定(bind)??

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) 或者你可以只切换绑定(bind),仅此而已 - 你需要确保检查安全设置等(基本和 wsHttpBinding 之间有所不同)

2) 您需要创建自己的自定义绑定(bind)并明确指定您需要的 SOAP 版本

关于c# - 如何更改 WCF 中的 SOAP 信封架构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2386306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com