c# - ASMX web service and error:- The content type text/html; charset=UTF-8 of the response message does not match the content type -


i trying call web service running in asp.net web application project. search google error message , found many link. people saying same thing web service returning error.

the below ways try call web service.

1st way

i add service reference of web service in win form , call below way.

servicereference1.searchdataindexsoapclient client = new servicereference1.searchdataindexsoapclient();         servicereference1.authheader authhead = new servicereference1.authheader();         authhead.password = "admin";         authhead.username = "admin";           console.writeline(client.startindex(authhead)); 

the last line return server 500 error details text "the content type text/html; charset=utf-8 of response message not match content type of binding (text/xml; charset=utf-8)"

2nd way

i used httpwebrequest class call web service without proxy getting same error.

3rd way

try call fiddler. give web service url , body. same error message when specify content type text/xml fiddler saw web service works fine , return right result.

so not being able understand can call web service fiddler when try call httpwebrequest or adding web reference getting error. set content type = text/xml when used httpwebrequest class no luck.

please me understand issue , guide me how fix calling httpwebrequest class or web reference. thanks

as have seen on web, correct web service throwing error. exception receive content type because service on error displays html page (text/html) when web service reference on client side expecting (text/xml). hope makes sense!

the root cause, error on web service. code, can confirm if web service method expecting parameter of type authheader or expected in soapheaders.

if expecting parameter of type authheader, put breakpoint in web service method or logging debug further.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -