Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, June 1, 2017

Solved : The content type of the response message does not match the content type of the binding


If you are adding any SOAP web service as just "Add Service Reference..." in Visual Studio and receiving below error at runtime in your code
 
System.ServiceModel.ProtocolException was unhandled
  HResult=-2146233087
  Message=The content type text/xml; charset=utf-8,text/xml; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?>

Follow below steps to fix this


  • Right click on VS project
  • Click on "Add Service Reference..."
  • Click on "Advanced..."
  • Click on "Add Web Reference..."
  • Enter service URL and click on Go arrow button
  • Enter Web Reference name and click on Add Reference
In short add SOAP service as a "Web Service" and don’t by just Service Reference in Visual Studio.

Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment