標籤:webservices
找到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卡**
使用WebServices調用網上的天氣手機服務