Read XML response from a webservice

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 56
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Read XML response from a webservice

 
0
  #1
Oct 13th, 2009
Hi, I've tried to get the geolocation of the clients IP, with this code:

  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:

  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
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC