Ody
Ody

Reputation: 2047

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

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?

Upvotes: 3

Views: 5218

Answers (1)

Vince
Vince

Reputation: 650

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.

Upvotes: 3

Related Questions