星空网 > 软件开发 > ASP.net

Asp.Net 天气 WebService 使用

本文使用Asp.Net  (C#)调用互联网上公开的WebServices(http://www.web

效果图 :

 

Asp.Net  天气 WebService  使用

 

 

步骤 :

1 、新建web 项目,添加窗体。Asp.Net  天气 WebService  使用

2 、 引用右键--> 添加服务引用-->高级--> 添加Web引用。

Asp.Net  天气 WebService  使用Asp.Net  天气 WebService  使用

Asp.Net  天气 WebService  使用

 

  

3 、 将Web接口复制到URL右边的框里-->点击输入框右边的箭头,测试连接(观察左下角看是否连接成功)--> 最右边可以更改Web引用名-->添加引用。

 

Asp.Net  天气 WebService  使用

Asp.Net  天气 WebService  使用

 

 Asp.Net  天气 WebService  使用

 

 

Asp.Net  天气 WebService  使用Asp.Net  天气 WebService  使用
 1 <div> 2    3     <br /> 4     <br /> 5 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Asp.Net 调用WebService实现天气预报<br /> 6     <br /> 7     <br /> 8 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 请输入城市名称:<asp:TextBox ID="txtcity" runat="server"></asp:TextBox> 9 &nbsp;&nbsp;10     <asp:Label ID="Label1" runat="server" style="color: red" BorderColor="Red" Text="如 :上海"></asp:Label>11     <br />12     <br />13 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;14     <asp:Button ID="btncheck" runat="server" Text="查询" Width="69px" OnClick="btncheck_Click" />15 &nbsp;16     <br />17 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 天气概况 : <asp:Label ID="lbtianqi" runat="server" style="" BorderColor="Red" Text=""></asp:Label>18     <br />19     <br />20 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 天气实况 :&nbsp;&nbsp; 21     <br />22 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;23     <asp:TextBox ID="txtcityweather" runat="server" Height="62px" TextMode="MultiLine" Width="258px"></asp:TextBox>24 &nbsp;&nbsp;25     <br />26     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;27     <br />28     <br />29     <br />30     <br />31     <br />32     <br />33   34   </div>

前台代码 
 
Asp.Net  天气 WebService  使用Asp.Net  天气 WebService  使用
 1 protected void btncheck_Click(object sender, EventArgs e) 2     { 3       WeatherService.WeatherWebService w = new WeatherService.WeatherWebService(); 4       string [] res=new string[23]; 5       string cityname = txtcity.Text.Trim(); 6       res = w.getWeatherbyCityName(cityname); 7       lbtianqi.Text = cityname + " "+res[6]; 8       txtcityweather.Text = res[10]; 9 10     }

后台代码

 


 



原标题:Asp.Net 天气 WebService 使用

关键词:ASP.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

eBay代征代缴英国增值税即将生效:https://www.ikjzd.com/articles/135797
巴基斯坦时装电商平台Clicky获70万美元Pre-A轮融资:https://www.ikjzd.com/articles/135811
eBay发布2021年汽配战略品类:https://www.ikjzd.com/articles/135812
京东国际黑五购物季成交额同比增长194%:https://www.ikjzd.com/articles/135813
考拉海购上线“手语识别系统” 助力听障主播直播:https://www.ikjzd.com/articles/135814
东南亚电商Zalora开启Harbolnas12.12大促:https://www.ikjzd.com/articles/135815
皇帝的皇宫=:https://www.vstour.cn/a/363188.html
海南岛琼海市旅游景点 琼海市的旅游景点:https://www.vstour.cn/a/363189.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流