c# - 在 C# 中将 Soap 请求 header 从 text/xml 更改为 soap/xml for asmx webservice

标签 c# xml web-services soap

我需要调用网络服务。我生成了一个代理并调用了该方法。但它一直在失败。因为 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/

相关文章:

c# - AutoMapper 未在映射时创建新的 Guid

c# - UWP 覆盖样式属性而不丢失其他属性定义

c# - CS0117 - Xamarin 未检测到 'Resources' 文件夹和文件

java - JMeter如何读取XML文件?

服务器或客户端的 Android 分页

c# - 如何在 Windows Phone 8.1 应用程序中扫描二维码? (不是 silverlight 应用程序)?

c# - 如何从具有不同签名的过程构造一个类

java - 使用 ant 根据 jar 属性编辑文件

android - 向 webservice 发送 json,接收 null。 - 安卓

c# - 向Web服务端口客户端添加cookie