Client found response content type of 'text/ht

2019-01-27 16:49发布

问题:

I am getting this error:

Client found response content type of 'text/html', but expected 'text/xml.

I am adding web reference for live search. When i build the project its Successful. But after that once i enter some text in textbox & enter search button it gives this error. I am Using my local machine & Using .net 2.0 with C#.
Plz help me...
Thanks In Advance...

回答1:

As Matt said, it's probably an error page coming back.

Either use a proxy like Fiddler or a network sniffer like WireShark to see what the raw response is - that should help you get to the bottom of what's going on.



回答2:

Generally that error means that the service has sent back an (HTML) error message rather than the XML SOAP response that your client was expecting.

For web services that you control it's really easy to find the problem, because you can invoke the webmethods by hand in your browser. To diagnose it when it's someone else's service is a little trickier. You might be able to trace into the code for your web reference and inspect the text of the response before the exception is thrown.



回答3:

I have found Fiddler to be highly useful in debugging http client server issues. It is a proxy that allows you to intercept and even change the content of the request and response.



回答4:

In your actual code, replace the line:

searchRequest.AppID = "APP ID you generated from ...";

with the actual AppID, which should be a long alpha-numeric sequence.



标签: c# .net-2.0