繁体   English   中英

无法连接远程服务器(Web 服务)

[英]Unable To connect remote server (Web Service)

在此处输入图片说明

我曾尝试将此 Web 服务集成到我的 asp.net 项目中,但它会弹出此类错误! 如果您对此有任何想法,请给我解决方案。 关于 oodle web services 和 oodle API 的资料非常少见。

试试这个 URL 对我的问题有更多的了解http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle/car

那根本就不是 SOAP Web 服务。 这是一个 REST XML 服务。 REST 服务不提供 WSDL 形式的自描述元数据。

您需要另一种与服务通信的方式。 如果没有可用的 C# 包装器,您可能必须自己编写 url 生成器,并让 .NET Framework 为您将 xml 文档反序列化为编写精美的类(您也可以自己编写)

尝试阅读更多内容: Oddle Developer Center

编辑:此外,如果您要从 Web 应用程序中下载 XML 文档,则需要考虑几件事情。

开发时,请确保以管理员身份运行 Visual Studio。

当您部署到您的托管服务提供商时,请确保您没有运行Medium Trust ,因为这可能会阻止您访问外部 Web 资源。

但是,我仍然无法弄清楚为什么“添加 Web 引用”对话框无法连接到 oodle Web 服务器。 检查您的网络设置、防火墙设置等。 如果您能够在 Web 浏览器中访问该 URL,则应该能够通过代码下载该文档。

try
    {
        string url = @"http://api.oodle.com/api/v2/listings?key=TEST&region=chicago";

        WebClient webClient = new WebClient();
        webClient.Encoding = Encoding.UTF8;
        string result = webClient.DownloadString(url);

       }
  catch (Exception ex)
    {
        Response.Write(ex.ToString());

    }

此语句创建异常

   string result = webClient.DownloadString(url);

和异常详细信息是

   System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt failed because the connected 
party did not properly respond after a period of time, or established connection failed 
because connected host has failed to respond 192.168.0.101:808 at 
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress 
socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, 
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, 
IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception 
stack trace --- at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& 
request) at System.Net.WebClient.DownloadString(Uri address) at 
System.Net.WebClient.DownloadString(String address) at _Default.lnkGoTo_Click(Object 
sender, EventArgs e) in d:\MyDemoz\oodleDemo\Default.aspx.cs:line 58 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM