【问题标题】:Adding Service Reference with encoding=ISO-8859-1 to Visual Studio 2013将 encoding=ISO-8859-1 的服务参考添加到 Visual Studio 2013
【发布时间】:2016-01-07 08:12:28
【问题描述】:

我有一个需要使用的自动生成的 Web 服务,以便我可以创建一个应用程序表单。问题是,当我尝试添加 web 服务时,它有一个错误

There was an error downloading 'http://bmctest016:8080/ctmbpi/TEST/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: %2Fctmbpi%2FTEST%2F%5Fvti%5Fbin%2FListData%2Esvc%2F%24metadata+Not+Found.
Metadata contains a reference that cannot be resolved: 'http://bmctest016:8080/ctmbpi/TEST'.
The content type text/html of the response message does not match the content type of the binding (application/soap+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: '<html>
<head>
<title>Error 500 com/sun/messaging/AdministeredObject</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2><pre>com/sun/messaging/AdministeredObject</pre>
<p>RequestURI=/ctmbpi/TEST</p>
<p><i><small><a href="http://jetty.mortbay.org">Powered by Jetty://</a></small></i></p>
'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

我注意到它无法从 Web 服务下载元数据,并且无法检查自动生成的 Web 服务。编码是 ISO-8859-1,根据研究,Visual Studio 2013 可以识别 UTF-8 网络服务,对吗?

是否可以更改 Visual Studio 中的设置以读取和识别使用 ISO-8859-1 编码的 Web 服务?我仍然不知道如何将自动生成的 web 服务更改为编码为 UTF-8,以便 Visual Studio 能够识别它。

附:该网络服务运行良好,并已成功通过多项测试。此外,SoapUI Tool 可以识别 Web 服务。

谢谢大家

【问题讨论】:

  • 为什么你认为这是一个编码问题??
  • 尝试在浏览器中打开“bmctest016:8080/ctmbpi/TEST/_vti_bin/ListData.svc”并查看完整的错误消息。
  • 我只是假设编码与 Visual Studio 不兼容,这就是为什么它无法下载元数据@JakobOlsen,这可能是我的错误吗?
  • @JakobOlsen,我试图打开上述 url,但我收到了这个错误(HTTP ERROR: 404 /ctmbpi/TEST/_vti_bin/ListData.svc Not Found RequestURI=/ctmbpi/TEST/_vti_bin/ListData .svc Powered by Jetty://)
  • 我认为这不是编码问题。您得到的错误是 http 404,这意味着您从服务器请求的页面无法找到。这就是为什么我希望你在浏览器中打开它。如果您甚至在浏览器中都看不到元数据,那么您就不能指望 Visual Studio 抓取它。

标签: c# xml visual-studio soap


【解决方案1】:

您可以添加 Web 引用而不是服务引用:

添加服务引用 -> 高级... -> 添加 Web 引用... -> 设置 WSDL / URL -> 添加引用

然后,设置请求编码:

WS client = new WS();
client.RequestEncoding = Encoding.GetEncoding("ISO-8859-1");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多