我需要调用网络服务。我生成了一个代理并调用了该方法。但它一直在失败。因为 API 需要 header 中的 soap/xml,而 Visual Studio 中生成的代理客户端在 header 中发送文本/xml。
问题:是否可以更改生成的代理客户端的 Content-Type header 的值?
最佳答案
Content Type text/xml; charset=utf-8 was not supported by service
this is usually a mismatch in the client/server bindings, where the message version in the service uses SOAP 1.2 (which expects application/soap+xml) and the version in the client uses SOAP 1.1 (which sends text/xml). WSHttpBinding uses SOAP 1.2, BasicHttpBinding uses SOAP 1.1.
它通常在一侧似乎是一个 wsHttpBinding 而在另一侧 另一个是 basicHttpBinding。
您可以将客户端的配置更改为使用 SOAP 1.2 的 WSHttpBinding,它会影响内容类型 header 。
关于c# - 在 C# 中将 Soap 请求 header 从 text/xml 更改为 soap/xml for asmx webservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26913574/