Unable To connect remote server (Web Service)
Asked Answered
F

2

6

enter image description here

I have tried to integrate this web service into my asp.net project but it popups such type of error ! If you have any idea regarding this kindly give me solution. There are very rare materials about oodle web services and 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

Falsework answered 27/1, 2012 at 15:30 Comment(0)
L
4

That simply isn't a SOAP Web Service. It's a REST XML service. REST services do not provide self-describing meta data in the form of 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).

Try reading more at: 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.

When you are developing, make sure you are running Visual Studio as an Administrator.

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.

But still, I can't figure out why the Add Web Reference dialog can't connect to the oodle web server. 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.

Lavinialavinie answered 27/1, 2012 at 15:33 Comment(4)
But how to get data from URL ? I mean totally new request and responses are generated ! So how can I map it ?Falsework
You can let WCF handle that for you. Here are a couple of pointers: blogs.msdn.com/b/pedram/archive/2008/04/21/… msdn.microsoft.com/en-us/magazine/dd315413.aspxLavinialavinie
...or you do it all manually. Then you need some method(s) for generating the proper urls, then use a WebClient object to create a request and then open the response Stream. Then there are a few different ways of getting the data back in a structured way. XmlDocument, XDocument or XmlSerializer are starting points...Lavinialavinie
Have a look on my answer ! Still it is !Falsework
F
4
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 
Falsework answered 31/1, 2012 at 11:39 Comment(7)
Read the error message. It tells you what is wrong. 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 Either the server times out or it refuses your connection for other reasons. Maybe there are only certain User-Agent values that are allowed... Are you able to visit the URL using your web browser? For me, it takes about 6 seconds to download the XML document using that URL. Does it take longer for you? Do you even get a result?Lavinialavinie
Oh, wait a minute... Is this a web app? Are you running Medium Trust? And again, are you running your Visual Studio instance as Administrator? Because when I run your code from within a Console App (using Console.WriteLine instead of Response.Write), it works perfectly. Try running VS as Admin! I updated my answer.Lavinialavinie
Let me run as Administrator !Falsework
Still Its not working !!! Let me try another way msdn.microsoft.com/en-us/library/456dfw4f.aspxFalsework
@atornblad Same error with new option !! Yaar I fed Up ! Let me try XML serialization !Falsework
XML Serialization won't help you here, because the error occurs before you even get anything back. There is a network error - not an XML serialization error.Lavinialavinie
let us continue this discussion in chatFalsework

© 2022 - 2024 — McMap. All rights reserved.