調用根據IP查看城市WebService

添加引用:http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx

.cs代碼

  //IP查詢省市
        protected void BindIP(string strIP)
        {
           IpAddressSearchWebServiceSoap IpSearch = new IpAddressSearchWebServiceSoapClient("IpAddressSearchWebServiceSoap");
            string[] infos = IpSearch.getCountryCityByIp(strIP);
            char[] strcity = { ' ' };
            string[] str = infos[1].ToString().Split(strcity);
            //infos[1] 顯示的是全部
            Response.Write("IP是:"+infos[0]+"  IP所在城市是:"+str[0]);        }

        protected void btnIP_Click(object sender, EventArgs e)
        {
            string strip = txtIP.Text;
            BindIP(strip);
        }

html代碼

 <asp:TextBox ID="txtIP" runat="server"></asp:TextBox>
 <asp:Button ID="btnIP" runat="server" Text="IP查詢城市" οnclick="btnIP_Click" />

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章