標籤:nbsp ref 檔案 [] pack soa java 空氣品質 代碼
<s:element ref="s:schema" />
<s:any />
<s:any minOccurs="2" maxOccurs="2" />
----------------------
免費的webservice介面:http://www.webxml.com.cn/zh_cn/web_services.aspx
天氣查詢的wsdl
http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl
view-source:http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl
號碼歸屬地的wsdl
http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl
1.在src下產生用戶端回應檔
可用wsdl檔案,或者地址產生,cmd命令視窗鎖定在src目錄下
2.用戶端類可查看wsdl文檔最後<wsdl:service />擷取
天氣代碼如下(wsdl不貼)
package com.atguigu.weather_client.test;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("上海", null); java.util.List<String> list = weather.getString(); System.out.println(list); for(String str:list){ System.out.println(str+"---"); } }}
運行結果:
[直轄市 上海, 上海, 2013, 2016/11/08 11:56:12, 今日天氣實況:氣溫:13℃;風向/風力:西南風 1級;濕度:66%, 紫外線強度:最弱。空氣品質:良。, 紫外線指數:最弱,輻射弱,塗擦SPF8-12防晒護膚品。感冒指數:極易發,強降溫,天氣寒冷,風力較強。穿衣指數:較冷,建議著厚外套加毛衣等服裝。洗車指數:不宜,有雨,雨水和泥水會弄髒愛車。運動指數:較不宜,有降水,推薦您在室內進行休閑運動。空氣汙染指數:良,氣象條件有利於空氣汙染物擴散。, 11月8日 小雨轉陰, 10℃/13℃, 北風4-5級轉3-4級, 7.gif, 2.gif, 11月9日 陰, 9℃/13℃, 北風微風, 2.gif, 2.gif, 11月10日 多雲轉晴, 9℃/15℃, 西北風微風, 1.gif, 0.gif, 11月11日 晴轉多雲, 12℃/18℃, 西風微風, 0.gif, 1.gif, 11月12日 多雲, 13℃/20℃, 南風微風, 1.gif, 1.gif]直轄市 上海---上海---2013---2016/11/08 11:56:12---今日天氣實況:氣溫:13℃;風向/風力:西南風 1級;濕度:66%---紫外線強度:最弱。空氣品質:良。---紫外線指數:最弱,輻射弱,塗擦SPF8-12防晒護膚品。感冒指數:極易發,強降溫,天氣寒冷,風力較強。穿衣指數:較冷,建議著厚外套加毛衣等服裝。洗車指數:不宜,有雨,雨水和泥水會弄髒愛車。運動指數:較不宜,有降水,推薦您在室內進行休閑運動。空氣汙染指數:良,氣象條件有利於空氣汙染物擴散。---11月8日 小雨轉陰---10℃/13℃---北風4-5級轉3-4級---7.gif---2.gif---11月9日 陰---9℃/13℃---北風微風---2.gif---2.gif---11月10日 多雲轉晴---9℃/15℃---西北風微風---1.gif---0.gif---11月11日 晴轉多雲---12℃/18℃---西風微風---0.gif---1.gif---11月12日 多雲---13℃/20℃---南風微風---1.gif---1.gif---
手機歸屬地如下:
package com.atguigu.phone;import cn.com.webxml.MobileCodeWS;import cn.com.webxml.MobileCodeWSSoap;public class ClientTest { public static void main(String[] args) { MobileCodeWS mobileCodeWS = new MobileCodeWS(); MobileCodeWSSoap mobile = mobileCodeWS.getMobileCodeWSSoap(); String mobileInfo = mobile.getMobileCodeInfo("15295087**", null); System.out.println(mobileInfo); }}
15295087**:江蘇 常州 江蘇移動全球通卡
該service借口經測試隱藏了一位號碼(大概為了安全吧)
07_編寫天氣預報和手機歸屬地的WebService