简体   繁体   English

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

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

在此处输入图片说明

I have tried to integrate this web service into my asp.net project but it popups such type of error !我曾尝试将此 Web 服务集成到我的 asp.net 项目中,但它会弹出此类错误! If you have any idea regarding this kindly give me solution.如果您对此有任何想法,请给我解决方案。 There are very rare materials about oodle web services and oodle API.关于 oodle web services 和 oodle API 的资料非常少见。

Try this URL to have more idea about my problem http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle/car试试这个 URL 对我的问题有更多的了解http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle/car

That simply isn't a SOAP Web Service.那根本就不是 SOAP Web 服务。 It's a REST XML service.这是一个 REST XML 服务。 REST services do not provide self-describing meta data in the form of WSDL. REST 服务不提供 WSDL 形式的自描述元数据。

You need another way of communicating with the service.您需要另一种与服务通信的方式。 If there isn't a C# wrapper available, you will probably have to write the url generator yourself, and have the .NET Framework deserialize the xml documents for you into nicely written classes (that you, also, write yourself) .如果没有可用的 C# 包装器,您可能必须自己编写 url 生成器,并让 .NET Framework 为您将 xml 文档反序列化为编写精美的类(您也可以自己编写)

Try reading more at: Oddle Developer Center尝试阅读更多内容: Oddle Developer Center

EDIT: Also, if you are downloading the XML document from within a web application, there are a couple of things you need to consider.编辑:此外,如果您要从 Web 应用程序中下载 XML 文档,则需要考虑几件事情。

When you are developing, make sure you are running Visual Studio as an Administrator .开发时,请确保以管理员身份运行 Visual Studio。

When you deploy to your hosting provider, make sure you are not running Medium Trust , because that might stop you from accessing external web sources.当您部署到您的托管服务提供商时,请确保您没有运行Medium Trust ,因为这可能会阻止您访问外部 Web 资源。

But still, I can't figure out why the Add Web Reference dialog can't connect to the oodle web server.但是,我仍然无法弄清楚为什么“添加 Web 引用”对话框无法连接到 oodle Web 服务器。 Check your network settings, your firewall settings and so on.检查您的网络设置、防火墙设置等。 If you are able to visit the URL in your web browser, you should be able to download the document through code.如果您能够在 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());

    }

This statement creates exception此语句创建异常

   string result = webClient.DownloadString(url);

and exception details are和异常详细信息是

   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