->new->Axis2 wizards
->Axis2 Cord Generator
-> Generate java source code from WSDL file
->WSDL file local->填写
http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl->
这里custom package name 改成 com.zyl.test
下面的http://WebXml.com.cn/也改成com.zyl.test
->output path 选你的项目 完成
package com.zyl.test;
import java.rmi.RemoteException;
public class TestWeather {
public static void main(String[] args) throws RemoteException {
WeatherWSStub weather = new WeatherWSStub();
WeatherWSStub.GetRegionCountry region_country = new WeatherWSStub.GetRegionCountry();
WeatherWSStub.ArrayOfString country = weather
.getRegionCountry(region_country).localGetRegionCountryResult;
String[] countries = country.localString;
for (String string : countries) {
System.out.println(string);
String[] mycountry = string.split(",");
System.out.println(mycountry[0] + ">>>>>>>" + mycountry[1]);
}
WeatherWSStub.GetRegionProvince region_province = new WeatherWSStub.GetRegionProvince();
WeatherWSStub.ArrayOfString province = weather
.getRegionProvince(region_province).localGetRegionProvinceResult;
String[] provincies = province.localString;
for (String string : provincies) {
System.out.println(string);
}
WeatherWSStub.GetSupportCityString region_city = new WeatherWSStub.GetSupportCityString();
region_city.setTheRegionCode("3114");
String[] cities = weather.getSupportCityString(region_city).localGetSupportCityStringResult.localString;
for (String string : cities) {
System.out.println(string);
}
WeatherWSStub.GetWeather city_weather = new WeatherWSStub.GetWeather();
city_weather.setTheCityCode("650");
String[] localweather = weather.getWeather(city_weather).localGetWeatherResult.localString;
for (String string : localweather) {
System.out.println(string);
}
}
}
Web Services查找天气预报
最新推荐文章于 2017-12-07 15:11:10 发布