944,066 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2270
  • ASP.NET RSS
Oct 13th, 2009
0

Read XML response from a webservice

Expand Post »
Hi, I've tried to get the geolocation of the clients IP, with this code:

vb Syntax (Toggle Plain Text)
  1. Dim rssReq As System.Net.WebRequest = _
  2. System.Net.WebRequest.Create("http://freegeoip.appspot.com/xml/" _
  3. & vl_bContadorVisitasBE.vcConVisIP)
  4.  
  5. 'Crear el Proxy
  6. Dim px As New System.Net.WebProxy("http://freegeoip.appspot.com/xml/" _
  7. & vl_bContadorVisitasBE.vcConVisIP, True)
  8.  
  9. 'Asignar el Proxy al objeto WebRequest
  10. rssReq.Proxy = px
  11.  
  12. 'Establecer el tiempo de vida al objeto WebRequest
  13. rssReq.Timeout = 2000
  14.  
  15. Try
  16. 'Obtener el objeto WebResponse
  17. Dim rep As System.Net.WebResponse = rssReq.GetResponse() [COLOR="Red"]<-- ERROR[/COLOR]
  18.  
  19. 'Insertar el objeto Response en el objeto XMLTextReader
  20. Dim xtr As New System.Xml.XmlTextReader(rep.GetResponseStream())
  21.  
  22. 'Insertar el objeto Response en el objeto DataSet
  23. ds.ReadXml(xtr)
  24.  
  25. Catch ex As Exception
  26.  
  27. End Try

But I keep getting the error "The underlying connection was closed: An unexpected error occurred on a receive." when executes the GetResponse line.

I tried to get better methods to do the same, but no luck.

The XML returned by the WS (http://freegeoip.appspot.com/xml/200.62.145.200) is something like this:

xml Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Response>
  3. <Status>true</Status>
  4. <Ip>200.62.145.200</Ip>
  5. <CountryCode>PE</CountryCode>
  6. <CountryName>Peru</CountryName>
  7. <RegionCode>15</RegionCode>
  8. <RegionName>Lima</RegionName>
  9. <City>Lima</City>
  10. <ZipCode />
  11. <Latitude>-12.05</Latitude>
  12. <Longitude>-77.05</Longitude>
  13. </Response>

So I need to parse into a ds or a dt, or something that I could read.

Thanks in advance.

Omar
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Viewstate
Next Thread in ASP.NET Forum Timeline: ASP.Net Validators Problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC