对项目添加web引用
http://webservice.36wu.com/weatherService.asmx
页面中引用命名空间
protected void Button1_Click(object sender, EventArgs e)
{
WeatherService weatherService = new WeatherService();
//返回内置实体City:城市,Cityid:城市Id(查询结果异常时“False”),Temp1~Temp6:六天的气温,Weather1~Weather6:六天的天气,Wind1~Wind6:六天的风向,Fl1~Fl6:六天的风力,Img1~Img12:六天天气图片
MoreWeathe moreWeathe = weatherService.getMoreWeatherByCityName(TextBox1.Text);
List<MoreWeathe> list = new List<MoreWeathe>();
list.Add(moreWeathe);
//将接果绑定在gridView上
GridView1.DataSource = list;
GridView1.DataBind();
}

本文介绍如何通过Web服务接口调用,获取指定城市的六天天气预报信息,并将其结果显示在网页上,包括城市、气温、天气状况、风向、风力等详细数据。
1001

被折叠的 条评论
为什么被折叠?



