Web引用 查询手机归属地、城市天气
2011-12-21 11:44
288 查看
http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx 天气预报链接
http://hi.baidu.com/oritenson/blog/item/d8688d526bf45c0e377abe1f.html 手机号码归属地
![](http://hi.csdn.net/attachment/201112/21/0_1324438674wJTx.gif)
添加web引用,将上面的网址Copy进去,
![](http://hi.csdn.net/attachment/201112/21/0_1324438875Q6O2.gif)
前台界面托几个控件如图
![](http://hi.csdn.net/attachment/201112/21/0_1324439007L2q7.gif)
下面开始是后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
this.DropDownList1.DataSource = wws.getSupportProvince();
this.DropDownList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
weblocalhost.WebService ws = new weblocalhost.WebService();
this.GridView1.DataSource = ws.GetStudent();
this.GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
string[] strs = wws.getWeatherbyCityName(this.DropDownList2.SelectedValue);
this.Label1.Text = strs[0] + "," + strs[1] + "<br/>";
Label1.Text += "温度:" + strs[5] + "<br/>";
Label1.Text += "风:" + strs[7];
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
BindCity(wws);
}
private void BindCity(cn.com.webxml.www.WeatherWebService wws)
{
this.DropDownList2.Items.Clear();
string[] strs = wws.getSupportCity(DropDownList1.SelectedValue);
foreach (string item in strs)
{
this.DropDownList2.Items.Add(new ListItem(item.Substring(0, item.IndexOf("("))));
}
}
protected void Button3_Click(object sender, EventArgs e)
{
cn.com.webxml.webservice.MobileCodeWS cww = new cn.com.webxml.webservice.MobileCodeWS();
this.Label2.Text = cww.getMobileCodeInfo(this.TextBox4.Text, "");
}
}
运行就可以实现天气和手机归属地的查询了。
http://hi.baidu.com/oritenson/blog/item/d8688d526bf45c0e377abe1f.html 手机号码归属地
![](http://hi.csdn.net/attachment/201112/21/0_1324438674wJTx.gif)
添加web引用,将上面的网址Copy进去,
![](http://hi.csdn.net/attachment/201112/21/0_1324438875Q6O2.gif)
前台界面托几个控件如图
![](http://hi.csdn.net/attachment/201112/21/0_1324439007L2q7.gif)
下面开始是后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
this.DropDownList1.DataSource = wws.getSupportProvince();
this.DropDownList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
weblocalhost.WebService ws = new weblocalhost.WebService();
this.GridView1.DataSource = ws.GetStudent();
this.GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
string[] strs = wws.getWeatherbyCityName(this.DropDownList2.SelectedValue);
this.Label1.Text = strs[0] + "," + strs[1] + "<br/>";
Label1.Text += "温度:" + strs[5] + "<br/>";
Label1.Text += "风:" + strs[7];
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
BindCity(wws);
}
private void BindCity(cn.com.webxml.www.WeatherWebService wws)
{
this.DropDownList2.Items.Clear();
string[] strs = wws.getSupportCity(DropDownList1.SelectedValue);
foreach (string item in strs)
{
this.DropDownList2.Items.Add(new ListItem(item.Substring(0, item.IndexOf("("))));
}
}
protected void Button3_Click(object sender, EventArgs e)
{
cn.com.webxml.webservice.MobileCodeWS cww = new cn.com.webxml.webservice.MobileCodeWS();
this.Label2.Text = cww.getMobileCodeInfo(this.TextBox4.Text, "");
}
}
运行就可以实现天气和手机归属地的查询了。
相关文章推荐
- WebServicel通过城市名查询天气
- WebServce查询免费的天气预报实例
- (作业)利用网络编程实现多个城市的天气查询
- 新浪天气预报接口 可一次查询多个城市天气
- 天气预报--保存已查询城市,历史记录功能实现
- 安卓查询当前所在地天气及查询地区(城市)代码cityCode localCode
- 输入城市名查询未来5天的天气
- 城市天气情况查询
- 城市天气查询(Java网络、面向对象、多线程、IO)
- android天气查询(一)websevice之ksoap2软件包的使用
- 微信公众号开发-输入城市查询天气
- PHP通过气象局开放API查询指定城市(区县)天气
- jquery这个webservice根据选择城市查询天气
- 调用天气api实现查询各城市天气
- flex调用webservices查询中国城市天气返回的是数组类型
- 我用vs2005写了一个webservice用来查询sql2005数据库中表值,返回一个dataset类型集合,测试时候显示的xml文档没有问题,但是当我添加web引用的时候却无法正常显示而且报错原因之一。
- 根据城市查询天气
- 心知天气api,根据城市名/id查询天气
- JSON方法查询某城市天气
- python界面查询各城市的天气