Web Services查找天气预报


->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);
}


}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值