http://webservice.36wu.com/weatherService.asmx
源码下载:点击打开链接
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <h1> 自动获取当天当地天气</h1> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <div style="background-image: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg'); width: 505px; height: 280px"> <div style="padding: 15px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("DateTime")%> <br /> <%#Eval("City")%> <br /> <%#Eval("Weather")%> <br /> <%#string.Format("{0}~{1}", Eval("Temp1"), Eval("Temp2"))%> <br /> <img src='<%# string.Format("PNG/{0}",Eval("Img1").ToString().Replace("gif","png")) %>' /><img src='<%# string.Format("PNG/{0}",Eval("Img2").ToString().Replace("gif","png")) %>' /> </div> </div> </ItemTemplate> </asp:Repeater> <h1> 自动获取未来五天天气</h1> <asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_1")%> <br /> <%# Eval("Temp1")%> <br /> <%#Eval("Weather1")%> <br /> <%#Eval("Wind1")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img1")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img2")) %>' /> </div> </div> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_2")%> <br /> <%# Eval("Temp2")%> <br /> <%#Eval("Weather2")%> <br /> <%#Eval("Wind2")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img3")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img4")) %>' /> <br /> </div> </div> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_3")%> <br /> <%# Eval("Temp3")%> <br /> <%#Eval("Weather3")%> <br /> <%#Eval("Wind3")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img5")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img6")) %>' /> <br /> </div> </div> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_4")%> <br /> <%# Eval("Temp4")%> <br /> <%#Eval("Weather4")%> <br /> <%#Eval("Wind4")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img7")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img8")) %>' /> <br /> </div> </div> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_5")%> <br /> <%# Eval("Temp5")%> <br /> <%#Eval("Weather5")%> <br /> <%#Eval("Wind5")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img9")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img10")) %>' /> <br /> </div> </div> <div style="float: left; background: url('http://php.weather.sina.com.cn/images/weather_yc_01.jpg') -510px 0px no-repeat; width: 168px; height: 253px;"> <div style="text-align: center; margin: 5px; width: 100%; height: 100%; color: White; line-height: 25px"> <%#Eval("City")%> <br /> <%#Eval("Date_6")%> <br /> <%# Eval("Temp6")%> <br /> <%#Eval("Weather6")%> <br /> <%#Eval("Wind6")%> <br /> <img src='<%# string.Format("PNG/{0}.png",Eval("Img11")) %>' /><img src='<%# string.Format("PNG/{0}.png",Eval("Img12")) %>' /> <br /> </div> </div> </ItemTemplate> </asp:Repeater> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using ServiceReference; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //今天天气 BindTodayWeather(); //获取未来五天 BindMoreWeather(); } } private void BindTodayWeather() { WeatherServiceSoapClient client = new WeatherServiceSoapClient(); //自动回去未来六天天气 //client.getAutomaticMoreWeather() //自动回去今天天气 //client.getAutomaticTodayWeather() //根据城市名或者区县名获取未来五天天气 //client.getMoreWeatherByCityName("市名或者区县名"); //根据ID获取未来五天天气 //client.getMoreWeatherByCityId("城市ID") //内置实体TodayWeather TodayWeather todayWeather = client.getAutomaticTodayWeather(); List<TodayWeather> list = new List<TodayWeather>(); list.Add(todayWeather); //将接果绑定在Repeater上 Repeater1.DataSource = list; Repeater1.DataBind(); } private void BindMoreWeather() { WeatherServiceSoapClient client = new WeatherServiceSoapClient(); //内置实体MoreWeather MoreWeather moreWeather = client.getAutomaticMoreWeather(); List<MoreWeather> list = new List<MoreWeather>(); Repeater2.DataSource = list; list.Add(moreWeather); Repeater2.DataBind(); } }