利用WebService自定义显示天气情况

简介: 下面这个地址是一个比较稳定的获取天气情况的WebService:http://www.webxml.

下面这个地址是一个比较稳定的获取天气情况的WebService:

http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 

 

这里用到里面的getWeatherbyCityName方法

 

(1)、首先添加服务引用 ,添加webservices的引用地址:

http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 

给起个名称为getWeather

 

(2)、在该网站下下载气象图片,将下载的weather文件夹放在网站根目录下的images文件夹下。

 

(3)、编写代码,获取信息:

 

 

 

<table width="100%"> <tr> <td style="width:10%"> <img src="images/rq.png" mce_src="images/rq.png" width="15" height="14" alt="" /> </td> <td > <asp:Label ID="lblTQ1" runat="server"></asp:Label> </td> <td > <asp:Image ID="imgTQPicture" runat="server" /> </td> <td > <asp:Label ID="lblTQ2" runat="server"></asp:Label> </td> </tr> </table> //调用WebService,返回天气信息 WeatherWebServiceSoapClient client = new WeatherWebServiceSoapClient("WeatherWebServiceSoap"); string[] weatherArray = new string[23]; string[] str = new string[23]; str = client.getWeatherbyCityName("合肥"); StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); sb.Append("今天是"); sb.Append(DateTime.Parse(str[4]).ToString("yyyy年MM月dd日")); sb2.Append(str[1]); sb2.Append(str[6].Substring(str[6].IndexOf(' '))); sb2.Append(str[5]); this.lblTQ1.Text = sb.ToString(); this.imgTQPicture.ImageUrl = @"images/weather/" + str[8]; this.lblTQ2.Text = sb2.ToString();

 

补充接口地址:

1、http://webservice.36wu.com/weatherService.asmx

 

 

 


 

相关文章
|
XML Java 数据格式
java WebService CXF Spring 自定义拦截器 附实例源码
java WebService CXF Spring 自定义拦截器 附实例源码
179 0
java WebService CXF Spring 自定义拦截器 附实例源码
|
XML Java Apache
java WebService CXF Spring 自定义拦截器 附实例源码
java WebService CXF Spring 自定义拦截器 附实例源码
195 0
java WebService CXF Spring 自定义拦截器 附实例源码
|
数据安全/隐私保护 网络架构 数据格式
|
C++
Sharepoint 2010 自定义WebService 找不到网站应用程序
错误描述:Net 开发WebService调用Microsoft.SharePoint.dll的服务器端对象模型,出现找不到网站的应用程序,或者出现500错误。 错误截图: [Webservice调用页错误] System.IO.FileNotFoundException: 找不到位于 http://localhost 的 Web 应用程序。
1009 0
|
XML 数据格式 小程序
WebService中运用自定义类的处理要领(转)
http://hi.baidu.com/cjhong_520/item/d7d1d595e4c048d91b49dfa9 最近一个项目要用到webservice调用业务层类,刚开始的时候遇到了一点小麻烦,经过这两天的总结和实践,终于总结出多个比较多见的情况下的处理要领。
830 0
|
.NET 开发框架
SharePoint 列表项通过自定义WebService读取
简述:给其他系统提供集成,发现SharePoint自带的WebService各种不好使,索性就自己写一点,也当做自己学习的记录了。当然内容比较简单,希望大侠们不要介意,也不要骂我啊。好了,进入正题吧。 1、 首先,使用VS2008新建一个WebService的项目,选择Asp.
900 0
|
5月前
|
缓存 应用服务中间件 数据库
Python Web Service开发及优化
随着互联网的快速发展,Web服务已成为现代技术的核心。Python作为一种功能强大且易于学习的编程语言,在Web服务开发领域占据着重要地位。Python Web服务开发的重要性在于它能够提供高效、可扩展且易于维护的解决方案。本篇博客将探讨如何使用Python的Flask框架、Gunicorn WSGI服务器和Nginx网页服务器来实现高性能的Web服务。
|
5月前
|
XML Java 应用服务中间件
WebService - Axis2基于JAX-WS开发WebService并发布多个WebService
WebService - Axis2基于JAX-WS开发WebService并发布多个WebService
80 0