Last post Apr 01, 2015 11:03 AM by sudip_inn
Mar 31, 2015 02:53 PM|sudip_inn|LINK
i was trying to call a web service running in my asp.net web application project. i search google just with error message and found many link. all people are saying same thing that your web service returning error.
the below ways i try to call web service.
i add service reference of web service in my win form and the call like below way.
ServiceReference1.SearchDataIndexSoapClient Client = new ServiceReference1.SearchDataIndexSoapClient();
ServiceReference1.AuthHeader authHead = new ServiceReference1.AuthHeader();
authHead.Password = "Admin";
authHead.Username = "Admin";
the last line return server 500 error with details text like "The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8)"
i used HttpWebRequest class to call my web service without proxy then also getting same error.
try to call by fiddler. just give web service url and body. get same error message but when i specify content type text/xml from fiddler then i saw web service works fine and return right result.
so just not being able to understand that i can call my web service properly by fiddler but when i try to call by HttpWebRequest or adding web reference then getting error. i also set content type = text/xml when used HttpWebRequest class but no
please help me to understand the issue and guide me how to fix it for calling by HttpWebRequest class or by web reference. thanks
Apr 01, 2015 10:23 AM|mgebhard|LINK
The most common reason for this is bug in the service logic that causes an exception. The service returns an HTML error response to the client but the client is expecting an XML response and throws an exception.
Please double check the Fiddler response content is not an error message.
Apr 01, 2015 11:03 AM|sudip_inn|LINK
solved. error was there in our web site which causes to access web service call.