C# 客户端发现响应内容类型为“text/html”,但应为“text/xml”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/490677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Client found response content type of 'text/html', but expected 'text/xml'
提问by
I am getting this error:
我收到此错误:
Client found response content type of 'text/html', but expected 'text/xml.
客户端发现响应内容类型为“text/html”,但预期为“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...
我正在添加用于实时搜索的网络参考。当我构建项目时,它成功了。但是在那之后,一旦我在文本框中输入一些文本并输入搜索按钮,它就会出现此错误。我正在使用我的本地机器并在 C# 中使用 .net 2.0。
请帮帮我...
提前致谢...
回答by Matt Hamilton
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.
通常,该错误意味着服务已发回 (HTML) 错误消息,而不是您的客户端所期望的 XML SOAP 响应。
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.
对于您控制的 Web 服务,很容易发现问题,因为您可以在浏览器中手动调用 webmethods。当它是其他人的服务时要诊断它有点棘手。您也许能够追踪到您的 Web 参考的代码并在引发异常之前检查响应的文本。
回答by Jon Skeet
回答by Jon Skeet
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
.
与实际AppID
,这应该是一个long alpha-numeric sequence
。