Change Soap Request Header from text/xml to soap/xml for asmx webservice in C#

我的未来我决定 提交于 2019-12-22 18:30:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/26913574/change-soap-request-header-from-text-xml-to-soap-xml-for-asmx-webservice-in-c-sh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!