天天看点

ASP.net 手机归属地查询(Web Service)

利用Web服务:实现手机归属地查询的功能。

项目右键添加web引用:

​​http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx​​ 

名称:

ChinaMobileCode

ASP.net 手机归属地查询(Web Service)

设计视图:

ASP.net 手机归属地查询(Web Service)

相关代码:

using System.Web.Services;  //添加

protected void Button1_Click(object sender, EventArgs e)
        {
            ChinaMobileCode.MobileCodeWS myChinaMobileCode = new ChinaMobileCode.MobileCodeWS();
            string mobileCode = myChinaMobileCode.getMobileCodeInfo(TextBox1.Text.Trim(), "");
            TextBox2.Text = mobileCode;
        }      

效果(随便输入的号码~~):