c# - 尝试将 Web 服务引用添加到项目时出现 HTTP 状态 400

标签 c# .net web-services wcf soap

我正在尝试添加 this WCF service reference到我的 Visual Studio 2012 C# 项目。当我尝试通过添加服务对话框加载服务时,出现此错误

There was an error downloading 'https://api.onecallnow.com/WebService/3.1/soap.svc/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: 'https://api.onecallnow.com/WebService/3.1/soap.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service https://api.onecallnow.com/WebService/3.1/soap.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again.

我查看了其他关于此错误的问题,但几乎所有问题都建议更改有关 WCF 服务配置的某些内容,我无权访问。

有人建议消息的最后一部分意味着我使用的 SOAP 版本与服务使用的版本不同,但我在“添加 Web 服务”对话框中看不到任何更改它的选项。

有人可以帮我正确添加这个服务引用吗?

最佳答案

如果您在浏览器中访问该服务,您将看到以下内容:

enter image description here

服务所有者已禁用元数据发布,因此您将无法通过“添加服务引用”对话框添加服务引用。

如果服务的所有者可以为您提供 WSDL 和其他元数据文件,您可以使用 ServiceModel Meatadata Utility Tool (SvcUtil.exe) 构建代理。 ;否则,他们可能有可供您使用的替代方法。

当然,前提是此服务旨在供公众使用。

关于c# - 尝试将 Web 服务引用添加到项目时出现 HTTP 状态 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21956160/

相关文章:

javascript - 主干解析 this.model.destroy

.net - 连接到数据库仍然更昂贵吗?

c# - Notepad 在底层与 PRINT 命令有何不同?

web-services - 如何在 fiddler 中编写对 REST Web 方法的请求

javascript - 从 JavaScript 调用 ASP.NET Web 服务方法

.net - 在 IIS 上发布 .NET6 C# Web 应用程序期间连接数据库时出错

c# - WPF RichTextBox 获取字符矩形

c# - 为什么我收到两倍于通过 UDP 广播发送的数据?

c# - 高性能C# TCP服务器问题: No connection could be made because the target machine actively refused it

c# - 将多个模型传递给 _Layout.cshtml,其中一个模型创建一个动态菜单