使用WebServices调用网上的天气手机服务

来源:互联网 发布:83式自行榴弹炮的数据 编辑:程序博客网 时间:2024/05/01 19:13

找到http://www.webxml.com.cn/zh_cn/index.aspx,里面有免费提供的手机归属地查询以及天气查询的webservices服务。

使用wsimport -keep SEI地址 把对应的客户端类生成出来。也可以把SEI地址对应的wsdl文档保存到本地,再使用wsimport读取本地的wsdl文档生成客户端类代码。


天气预报:



ClientTest代码:

package com.wiseweb.weather_client_test;import java.util.List;import cn.com.webxml.ArrayOfString;import cn.com.webxml.WeatherWS;import cn.com.webxml.WeatherWSSoap;public class ClientTest {public static void main(String[] args) {WeatherWS weatherWS = new WeatherWS() ;WeatherWSSoap weatherWSSoap = weatherWS.getWeatherWSSoap() ;ArrayOfString weather = weatherWSSoap.getWeather("北京", "") ;List<String> list = weather.getString() ;System.out.println(list);}}

运行结果:

[直辖市 北京, 北京, 792, 2015/03/03 10:10:03, 今日天气实况:气温:0℃;风向/风力:北风 4级;湿度:11%, 空气质量:暂无;紫外线强度:弱, 太阳镜指数:非常必要。白天出行建议佩戴有防风沙功能的太阳镜。穿衣指数:寒冷。建议着厚羽绒服等隆冬服装。旅游指数:较不宜。大风可能不利出行,需带上防风衣物。运动指数:较不宜。风力很大,推荐您进行室内运动。洗车指数:较不宜。风力较大,洗车后会蒙上灰尘。化妆指数:保湿。请选用滋润保湿型化妆品。感冒指数:极易发。强降温,天气寒冷,风力较强。空气污染指数:暂无。紫外线指数:弱。辐射较弱,涂擦SPF12-15、PA+护肤品。舒适度指数:较不舒适。白天较凉,风力较强,偏冷。, 3月3日 多云, -4℃/4℃, 北风5-6级转3-4级, 1.gif, 1.gif, 3月4日 晴转多云, -5℃/5℃, 无持续风向微风, 0.gif, 1.gif, 3月5日 晴转多云, -3℃/8℃, 无持续风向微风, 0.gif, 1.gif, 3月6日 多云, -1℃/9℃, 无持续风向微风, 1.gif, 1.gif, 3月7日 多云转晴, 0℃/9℃, 无持续风向微风, 1.gif, 0.gif]



手机归属地查询:



PhoneTest:

package com.wiseweb.phone_client_test;import cn.com.webxml.MobileCodeWS;import cn.com.webxml.MobileCodeWSSoap;public class PhoneTest {public static void main(String[] args) {MobileCodeWS mobileCodeWS = new MobileCodeWS() ;MobileCodeWSSoap mobileCodeWSSoap = mobileCodeWS.getMobileCodeWSSoap() ;String result = mobileCodeWSSoap.getMobileCodeInfo("18513429793", "") ;System.out.println(result + "**");}}

运行结果:
18513429793:北京 北京 北京联通GSM卡**


0 0
原创粉丝点击