在 C# 中,将 Soap 请求头从 text/xml 更改为 soap/xml 以获取 asmx webservice [英] Change Soap Request Header from text/xml to soap/xml for asmx webservice in C#
问题描述
我需要调用网络服务.我生成了一个代理并调用了该方法.但它一直失败.因为 API 期望在标头中使用soap/xml,而在Visual Studio 中生成的代理客户端在标头中发送文本/xml.
问题:是否可以更改生成的代理客户端的 Content-Type 标头的值?
Content Type text/xml;服务不支持 charset=utf-8
<块引用><块引用>这通常是客户端/服务器绑定中的不匹配,其中服务中的消息版本使用 SOAP 1.2(期望application/soap+xml) 并且客户端中的版本使用 SOAP 1.1(发送文本/xml).WSHttpBinding 使用 SOAP 1.2,BasicHttpBinding使用 SOAP 1.1.
它通常似乎是一侧的 wsHttpBinding 和另一个是 basicHttpBinding.
您可以将客户端的配置更改为使用 SOAP 1.2 的 WSHttpBinding,它会影响内容类型标头.
I need to call a webservice. I generated a proxy and invoked the method. But it keeps failing. Because the API is expecting soap/xml in the header whereas the proxy client generated in Visual studio is sending text/xml in header.
Question: Is it possible to change the value of the Content-Type header for a generated proxy client?
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.
It usually seems to be a wsHttpBinding on one side and a basicHttpBinding on the other.
You can change the configuration on the client side to WSHttpBinding which uses SOAP 1.2 and it will affect the content type header.
这篇关于在 C# 中,将 Soap 请求头从 text/xml 更改为 soap/xml 以获取 asmx webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!