[英]get xml from webservice
我需要调用一个返回此xml的Web服务
<Response>
<statusCode>OK</statusCode>
<statusMessage/>
<ipAddress>127.0.0.1</ipAddress>
<countryCode>-</countryCode>
<countryName>-</countryName>
<regionName>-</regionName>
<cityName>-</cityName>
<zipCode>-</zipCode>
<latitude>0</latitude>
<longitude>0</longitude>
<timeZone>-</timeZone>
</Response>
这是URL:
String userIp = HttpContext.Current.Request.UserHostAddress;
// api key
String api_key = "01cce0db52b4eafaf8eac3f5b560fa4b5bf20f1410763224557d05eb949a2b3c";
// service url
String api_url = "http://api.ipinfodb.com/v3/ip-city/?key=" +api_key +"&ip="+ userIp +"&format=xml";
我怎么能在asp中捕获它? 我尝试使用Web服务,但无法解决。
您可以使用John Saunders方法并调用WebClient.DownloadString
你只需要这样做......
WebClient client = new WebClient();
string result = client.DownloadString(api_url);
然后,字符串result
应包含从URL下载的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.