Function Description:
This interface is used to obtain the IP address to which the client accesses the region (country, city, etc.). Query the country, city, owner and other information by entering the IP address. No country specified for China input parameter: IP address (auto replace). "For". " ), return data: A one-dimensional string array of string (1), string (0) = IP address; string (1) = country, city, owner, etc.
1.1.1. Interface Address
WebService Way:
Example: Http://webservice.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?op=getCountryCityByIp
1.1.2. Method Name
Getcountrycitybyip
1.1.3. Parameter Description Request Parameters:
Parameter name |
Chinese meaning |
Type |
Must fill in |
Note |
No |
32 bits binary number |
String |
Is |
For example: "127.0.0.1" |
No |
32 bits binary number |
String |
Is |
For example: "218.108.242.108" |
return Result:
Parameter name |
Chinese meaning |
Type |
Must fill in |
Note |
String[] Strarea_ip |
Returns an array that contains IP information |
String [] |
Whether |
For example: count=2, which indicates an array length of 2 (0,1) |
STRAREA_IP[0] |
IP address requested by the client |
String |
Whether |
For example: "218.108.242.108" |
STRAREA_IP[1] |
IP Address Region information |
String |
Whether |
For example: "Hangzhou, Zhejiang" |
|
|
|
|
|
The following is the IP parameter passed in to obtain the owning zone:
According to the third party website (WebService provider), by crawling the Internet IP address of the computer on this website to obtain the IP address of the client to the region.
Of course, if that day this site changed the domain name or does not exist, this method will not be used properly Oh!
The next thing is very simple, add the above webservice to the project, and then call this webservice to get the area of the Internet.
The code is specifically implemented as follows:
/// <summary> ///get the area of the Internet IP/// </summary> /// <returns></returns> Private stringGetconnectnetaddressarea () {stringStrIP = "218.108.242.108;//the requested IP addressIpaddresssearchwebservice WebService=NewIpaddresssearchwebservice (); string[] strarea_ip=Webservice.getcountrycitybyip (StrIP); returnstrarea_ip[1];//return Result: "Hangzhou, Zhejiang"}
View Code
. NET (C #) Call WebService get client IP address zone (non-async)