3

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?

Ody
  • 2,012
  • 4
  • 25
  • 35
  • This may help: https://social.msdn.microsoft.com/Forums/vstudio/en-US/32e62554-dbe5-483b-830f-df1d2b22a845/client-found-response-content-type-of-but-expected-textxml?forum=wcf – sr28 Nov 13 '14 at 16:56

1 Answers1

3

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.

Community
  • 1
  • 1
Vince
  • 620
  • 1
  • 5
  • 9
  • Thanks for the reply. I was able to change the binding to wsHttpBinding and it now sends `application/soap+xml`. But the endpoint is rejecting the request because it is expecting `soap/xml` explicitly – Ody Nov 13 '14 at 17:21
  • This saved me! Thanks! :-) – Cheshire Cat May 17 '17 at 12:31