答案:例就调用 http://www.webxml.com.cn/zh_cn/index.aspx这个网站上的手机号码归属地查询首先新建一个asp.net项目,添加一个Default.aspx页面。在建好的项目上右键(添加web引用)。弹出如下界面
然后在栏目里输入EndPoint,点击前往。如下图
对于webservice的每个接口函数,都有参数和返回值的说明。点击右边的添加引用,即可完成引用。
asp.net页面如下
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="归属地查询" />
<asp:Label ID="Label1" runat="server" ForeColor="#CC0066"></asp:Label>
</div>
</form>
</body>
点击归属地查询按钮,写如下代码,在写代码之前我们看看引用的webservice结构什么意思,自己领悟,代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
cn.com.webxml.webservice.MobileCodeWS mw = new cn.com.webxml.webservice.MobileCodeWS();
this.Label1.Text= mw.getMobileCodeInfo(TextBox1.Text, "");
}运行效果如下:
先在网上找个web服务网站,然后在项目中添加web引用!
web service,调用相应接口
上一个:求好心人讲解一下asp.net代码
下一个:帮我看段asp.net的代码。