`
张玉龙
  • 浏览: 722623 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

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

	}

}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics