自定义天气WCF服务接口 转载自作者Selway
一、概要:
此天气WCF使用的是中国天气的Json天气数据接口。
另外,由于文章并没有讲解具体的WCF创建过程,所以在文章最后笔者会提供一个笔者自己的完成品以供大家参考。
地址:http://m.weather.com.cn/data/101120201.html
其中101120201就是每个城市的代码。
Json数据的基本结构
1 View Code 2 { 3 "weatherinfo": 4 { 5 //基本信息 6 "city":"青岛", 7 "city_en":"qingdao", 8 "date_y":"2013年4月2日", 9 "date":"","week":"星期二", 10 "fchh":"08", 11 "cityid":"101120201", 12 //未来1到6天的天气信息 13 "temp1":"12℃~4℃","temp2":"13℃~6℃","temp3":"12℃~7℃","temp4":"9℃~3℃","temp5":"7℃~-1℃","temp6":"7℃~2℃", 14 "tempF1":"53.6℉~39.2℉","tempF2":"55.4℉~42.8℉","tempF3":"53.6℉~44.6℉","tempF4":"48.2℉~37.4℉","tempF5":"44.6℉~30.2℉","tempF6":"44.6℉~35.6℉", 15 "weather1":"晴","weather2":"晴转多云","weather3":"多云转阴","weather4":"小雨","weather5":"多云","weather6":"晴", 16 //图片一天两个:白天和今晚,单数白天,双数夜晚 17 "img1":"0","img2":"99","img3":"0","img4":"1","img5":"1","img6":"2", 18 "img7":"7","img8":"99","img9":"1","img10":"99","img11":"0","img12":"99","img_single":"0", 19 "img_title1":"晴","img_title2":"晴","img_title3":"晴","img_title4":"多云","img_title5":"多云","img_title6":"阴", 20 "img_title7":"小雨","img_title8":"小雨","img_title9":"多云","img_title10":"多云","img_title11":"晴","img_title12":"晴","img_title_single":"晴", 21 "wind1":"北风4-5级转南风3-4级","wind2":"南风3-4级","wind3":"东南风3-4级","wind4":"东南风4-5级","wind5":"北风5-6级","wind6":"南风4-5级","fx1":"北风","fx2":"南风", 22 "fl1":"4-5级转3-4级","fl2":"3-4级","fl3":"3-4级","fl4":"4-5级","fl5":"5-6级","fl6":"4-5级", 23 //穿衣指数 24 "index":"较冷", 25 "index_d":"建议着厚外套加毛衣等服装。年老体弱者宜着大衣、呢外套加羊毛衫。", 26 "index48":"较冷", 27 "index48_d":"建议着厚外套加毛衣等服装。年老体弱者宜着大衣、呢外套加羊毛衫。", 28 //紫外线指数 29 "index_uv":"中等", 30 "index48_uv":"中等", 31 //洗车指数 32 "index_xc":"较适宜", 33 //旅游指数 34 "index_tr":"适宜", 35 //舒适指数 36 "index_co":"较舒适", 37 //这个我也不清楚,应该是和舒适指数相关的信息 38 "st1":"11","st2":"3","st3":"12","st4":"4","st5":"12","st6":"4", 39 //晨练指数 40 "index_cl":"较适宜", 41 //晾晒指数 42 "index_ls":"基本适宜", 43 //过敏指数 44 "index_ag":"极易发" 45 } 46 }
使用此接口的优点是比较稳定,信息也比较准确。缺点是比较容易找到的城市代号目前只有省级市的,像一些县级市只能根据情况自己添加了。(最后笔者会提供一个Json结构的城市列表)
实现此天气的WCF服务,主要可分为四个功能:
1、根据IP获取用户的所有省份和城市。(如果需要自动识别用户地理位置返回天气情况的话)
4、获取此服务所有支持的城市。(此功能作为附加,更方便使用者)
二、数据结构
1、城市基本天气信息
1 View Code 2 /// <summary> 3 /// 城市基本天气信息 4 /// </summary> 5 public class WeatherInformation 6 { 7 string city = string.Empty; 8 [DataMember] 9 /// <summary> 10 /// 中文城市名称 11 /// </summary> 12 public string City 13 { 14 get { return city; } 15 set { city = value; } 16 } 17 18 string cityEn = string.Empty; 19 [DataMember] 20 /// <summary> 21 /// 英文城市名称 22 /// </summary> 23 public string CityEn 24 { 25 get { return cityEn; } 26 set { cityEn = value; } 27 } 28 29 string date = string.Empty; 30 [DataMember] 31 /// <summary> 32 /// 中文日期 33 /// </summary> 34 public string Date 35 { 36 get { return date; } 37 set { date = value; } 38 } 39 40 string dateEn = string.Empty; 41 [DataMember] 42 /// <summary> 43 /// 英文日期 44 /// </summary> 45 public string DateEn 46 { 47 get { return dateEn; } 48 set { dateEn = value; } 49 } 50 51 string week = string.Empty; 52 [DataMember] 53 /// <summary> 54 /// 中文星期 55 /// </summary> 56 public string Week 57 { 58 get { return week; } 59 set { week = value; } 60 } 61 62 string weekEn = string.Empty; 63 [DataMember] 64 /// <summary> 65 /// 英文星期 66 /// </summary> 67 public string WeekEn 68 { 69 get { return weekEn; } 70 set { weekEn = value; } 71 } 72 73 string published = string.Empty; 74 [DataMember] 75 /// <summary> 76 /// 发布时间 77 /// </summary> 78 public string Published 79 { 80 get { return published; } 81 set { published = value; } 82 } 83 84 string cityCode = string.Empty; 85 [DataMember] 86 /// <summary> 87 /// 城市代码 88 /// </summary> 89 public string CityCode 90 { 91 get { return cityCode; } 92 set { cityCode = value; } 93 } 94 95 List<Weather> weatherForecast = new List<Weather>(); 96 [DataMember] 97 /// <summary> 98 /// 表示从今天开始连续6天的天气情况 99 /// </summary> 100 public List<Weather> WeatherForecast 101 { 102 get { return weatherForecast; } 103 set { weatherForecast = value; } 104 } 105 106 string dressingIndex24 = string.Empty; 107 [DataMember] 108 /// <summary> 109 /// 24小时穿衣指数 110 /// </summary> 111 public string DressingIndex24 112 { 113 get { return dressingIndex24; } 114 set { dressingIndex24 = value; } 115 } 116 117 string dressingIndexDescription24 = string.Empty; 118 [DataMember] 119 /// <summary> 120 /// 24小时穿衣指数描述信息 121 /// </summary> 122 public string DressingIndexDescription24 123 { 124 get { return dressingIndexDescription24; } 125 set { dressingIndexDescription24 = value; } 126 } 127 128 string dressingIndex48 = string.Empty; 129 [DataMember] 130 /// <summary> 131 /// 48小时穿衣指数 132 /// </summary> 133 public string DressingIndex48 134 { 135 get { return dressingIndex48; } 136 set { dressingIndex48 = value; } 137 } 138 139 string dressingIndexDescription48 = string.Empty; 140 [DataMember] 141 /// <summary> 142 /// 48小时穿衣指数描述 143 /// </summary> 144 public string DressingIndexDescription48 145 { 146 get { return dressingIndexDescription48; } 147 set { dressingIndexDescription48 = value; } 148 } 149 150 string UVindex24 = string.Empty; 151 [DataMember] 152 /// <summary> 153 /// 24小时紫外线指数 154 /// </summary> 155 public string UVIndex24 156 { 157 get { return UVindex24; } 158 set { UVindex24 = value; } 159 } 160 161 string UVindex48 = string.Empty; 162 [DataMember] 163 /// <summary> 164 /// 48小时紫外线指数 165 /// </summary> 166 public string UVIndex48 167 { 168 get { return UVindex48; } 169 set { UVindex48 = value; } 170 } 171 172 string carWashIndex = string.Empty; 173 [DataMember] 174 /// <summary> 175 /// 洗车指数 176 /// </summary> 177 public string CarWashIndex 178 { 179 get { return carWashIndex; } 180 set { carWashIndex = value; } 181 } 182 183 string turismIndex = string.Empty; 184 [DataMember] 185 /// <summary> 186 /// 旅游指数 187 /// </summary> 188 public string TurismIndex 189 { 190 get { return turismIndex; } 191 set { turismIndex = value; } 192 } 193 194 string comfortIndex = string.Empty; 195 [DataMember] 196 /// <summary> 197 /// 舒适指数 198 /// </summary> 199 public string ComfortIndex 200 { 201 get { return comfortIndex; } 202 set { comfortIndex = value; } 203 } 204 205 string morningExerciseIndex = string.Empty; 206 [DataMember] 207 /// <summary> 208 /// 晨练指数 209 /// </summary> 210 public string MorningExerciseIndex 211 { 212 get { return morningExerciseIndex; } 213 set { morningExerciseIndex = value; } 214 } 215 216 string dryingIndex = string.Empty; 217 [DataMember] 218 /// <summary> 219 /// 晾晒指数 220 /// </summary> 221 public string DryingIndex 222 { 223 get { return dryingIndex; } 224 set { dryingIndex = value; } 225 } 226 227 string allergyIndex = string.Empty; 228 [DataMember] 229 /// <summary> 230 /// 过敏指数 231 /// </summary> 232 public string AllergyIndex 233 { 234 get { return allergyIndex; } 235 set { allergyIndex = value; } 236 } 237 }
2、天气实体类
1 View Code 2 /// <summary> 3 /// 天气实体类 4 /// </summary> 5 public class Weather 6 { 7 string celsius = string.Empty; 8 [DataMember] 9 /// <summary> 10 /// 摄氏温度 11 /// </summary> 12 public string Celsius 13 { 14 get { return celsius; } 15 set { celsius = value; } 16 } 17 18 string fahrenheit = string.Empty; 19 [DataMember] 20 /// <summary> 21 /// 华氏温度 22 /// </summary> 23 public string Fahrenheit 24 { 25 get { return fahrenheit; } 26 set { fahrenheit = value; } 27 } 28 29 string weatherDescription = string.Empty; 30 [DataMember] 31 /// <summary> 32 /// 天气描述 33 /// </summary> 34 public string WeatherDescription 35 { 36 get { return weatherDescription; } 37 set { weatherDescription = value; } 38 } 39 40 string weatherImageNo = string.Empty; 41 [DataMember] 42 /// <summary> 43 /// 天气描述图片序号 44 /// </summary> 45 public string WeatherImageNo 46 { 47 get { return weatherImageNo; } 48 set { weatherImageNo = value; } 49 } 50 51 string imageTitle = string.Empty; 52 [DataMember] 53 /// <summary> 54 /// 图片名称 55 /// </summary> 56 public string ImageTitle 57 { 58 get { return imageTitle; } 59 set { imageTitle = value; } 60 } 61 62 string windDescription = string.Empty; 63 [DataMember] 64 /// <summary> 65 /// 风速描述 66 /// </summary> 67 public string WindDescription 68 { 69 get { return windDescription; } 70 set { windDescription = value; } 71 } 72 73 string windSpeedLevel = string.Empty; 74 [DataMember] 75 /// <summary> 76 /// 风速级别描述 77 /// </summary> 78 public string WindSpeedLevel 79 { 80 get { return windSpeedLevel; } 81 set { windSpeedLevel = value; } 82 } 83 }
三、实现
配置的Web.config
1 <appSettings> 2 <!--根据IP获取城市的网址--> 3 <add key = "GetCityByIP" value = "http://pv.sohu.com/cityjson"/> 4 <!--获取天气的网址--> 5 <add key = "GetWeather" value = "http://m.weather.com.cn/data/{0}.html"/> 6 </appSettings>
本文解析Json使用的是开源的娄库Newtonsoft.Json(下载地址http://json.codeplex.com/)
通过WebClient的DownloadString()访问网址下载数据并解析,获取城市。这种接口网上还是比较多的,此处采用的是搜狐的:http://pv.sohu.com/cityjson
详细实现如下
1 View Code 2 /// <summary> 3 /// 根据IP返回IP所在城市 4 /// </summary> 5 /// <returns></returns> 6 public string GetCityName() 7 { 8 string url = ConfigurationManager.AppSettings["GetCityByIP"]; 9 WebClient wc = new WebClient(); 10 string cityJson = string.Empty; 11 string provincesAndCity = string.Empty; 12 string provinces = string.Empty; 13 string city = string.Empty; 14 try 15 { 16 cityJson = wc.DownloadString(url); 17 cityJson = cityJson.Replace("var returnCitySN = ", ""); 18 cityJson = cityJson.Replace(";", ""); 19 JObject JObjtCity = (JObject)JsonConvert.DeserializeObject(cityJson); 20 provincesAndCity = JObjtCity["cname"].ToString(); 21 22 provinces = provincesAndCity.Substring(0, provincesAndCity.IndexOf("省") + 1); 23 city = provincesAndCity.Substring(provincesAndCity.IndexOf("省") + 1); 24 } 25 catch (Exception) 26 { 27 throw new FaultException<Exception>(new Exception(), new Exception().Message); 28 } 29 return provincesAndCity; 30 }
城市列表可以以变量形式存在内存中,但最好还是存在文件中比较好日后扩展也相对好方便许多。
详细实现如下
1 View Code 2 /// <summary> 3 /// 根据城市名称返回城市代号 4 /// 城市名称可以有多种形式,如: 5 /// 青岛 6 /// 青岛市 7 /// 山东青岛 8 /// 山东青岛市 9 /// 山东省青岛市 10 /// </summary> 11 /// <param name="cityName">城市名称</param> 12 /// <returns></returns> 13 private string GetCityCode(string cityName) 14 { 15 StreamReader sr = File.OpenText(AppDomain.CurrentDomain.RelativeSearchPath + @"\CityCode.Json.txt"); 16 string strCityCodeJson = sr.ReadToEnd(); 17 JObject JObjtCityCode = (JObject)JsonConvert.DeserializeObject(strCityCodeJson); 18 bool isFound = false; 19 string cityCode = string.Empty; 20 for (int i = 0; i < JObjtCityCode["城市代码"].Count(); i++) 21 { 22 for (int j = 0; j < JObjtCityCode["城市代码"][i]["市"].Count(); j++) 23 { 24 //此为了实现多种城市形式匹配,所以添加多个判断 25 if (JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString() == cityName 26 || String.Format("{0}市", JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString()) == cityName 27 || String.Format("{0}{1}", JObjtCityCode["城市代码"][i]["省"].ToString(), JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString()) == cityName 28 || String.Format("{0}{1}市", JObjtCityCode["城市代码"][i]["省"].ToString(), JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString()) == cityName 29 || String.Format("{0}省{1}", JObjtCityCode["城市代码"][i]["省"].ToString(), JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString()) == cityName 30 || String.Format("{0}省{1}市", JObjtCityCode["城市代码"][i]["省"].ToString(), JObjtCityCode["城市代码"][i]["市"][j]["市名"].ToString()) == cityName) 31 { 32 cityCode = JObjtCityCode["城市代码"][i]["市"][j]["编码"].ToString(); 33 isFound = true; 34 break; 35 } 36 isFound = false; 37 } 38 if (isFound) 39 break; 40 } 41 return cityCode; 42 }
详细实现如下
1 View Code 2 /// <summary> 3 /// 根据城市名称返回城市天气情况 4 /// 城市名称可以有多种形式,如: 5 /// 青岛 6 /// 青岛市 7 /// 山东青岛 8 /// 山东青岛市 9 /// 山东省青岛市 10 /// </summary> 11 /// <param name="cityName">城市名称</param> 12 /// <returns></returns> 13 public WeatherInformation GetWeatherByCityName(string cityName) 14 { 15 string cityCode = this.GetCityCode(cityName); 16 if (cityCode == string.Empty) 17 return null; 18 string url = ConfigurationManager.AppSettings["GetWeather"]; 19 WebClient wc = new WebClient(); 20 string weatherJson = string.Empty; 21 WeatherInformation weatherInfomation = new WeatherInformation(); 22 try 23 { 24 wc.Encoding = Encoding.UTF8; 25 weatherJson = wc.DownloadString(String.Format(url, cityCode)); 26 JObject JObjtWeather = (JObject)JsonConvert.DeserializeObject(weatherJson); 27 JObjtWeather = (JObject)JObjtWeather["weatherinfo"]; 28 weatherInfomation.City = JObjtWeather["city"].ToString(); 29 weatherInfomation.CityEn = JObjtWeather["city_en"].ToString(); 30 weatherInfomation.Date = JObjtWeather["date_y"].ToString(); 31 weatherInfomation.DateEn = DateTime.Now.ToString("yyyy-MM-dd"); 32 weatherInfomation.Week = JObjtWeather["week"].ToString(); 33 weatherInfomation.WeekEn = this.GetWeekEn(weatherInfomation.Week); 34 weatherInfomation.Published = JObjtWeather["fchh"].ToString(); 35 weatherInfomation.CityCode = JObjtWeather["cityid"].ToString(); 36 /***************从今天开始到第6天天气情况*************************/ 37 for (int i = 1; i < 7; i ++) 38 { 39 Weather weather = new Weather(); 40 weather.Celsius = JObjtWeather[String.Format("temp{0}", i)].ToString(); 41 weather.Fahrenheit = JObjtWeather[String.Format("tempF{0}", i)].ToString(); 42 weather.WeatherDescription = JObjtWeather[String.Format("weather{0}", i)].ToString(); 43 //此处使用(i*2)-1 因为“中国天气”中显示图标方式是每天两个:白天和夜晚,而此处只取了白天的 44 weather.WeatherImageNo = JObjtWeather[String.Format("img{0}", (i * 2) -1)].ToString(); 45 weather.ImageTitle = JObjtWeather[String.Format("img_title{0}", (i * 2) - 1)].ToString(); 46 weather.WindDescription = JObjtWeather[String.Format("wind{0}", i)].ToString(); 47 weather.WindSpeedLevel = JObjtWeather[String.Format("fl{0}", i)].ToString(); 48 weatherInfomation.WeatherForecast.Add(weather); 49 } 50 /****************************************************************/ 51 weatherInfomation.DressingIndex24 = JObjtWeather["index"].ToString(); 52 weatherInfomation.DressingIndexDescription24 = JObjtWeather["index_d"].ToString(); 53 weatherInfomation.DressingIndex48 = JObjtWeather["index48"].ToString(); 54 weatherInfomation.DressingIndexDescription48 = JObjtWeather["index48_d"].ToString(); 55 weatherInfomation.UVIndex24 = JObjtWeather["index_uv"].ToString(); 56 weatherInfomation.UVIndex48 = JObjtWeather["index48_uv"].ToString(); 57 weatherInfomation.CarWashIndex = JObjtWeather["index_xc"].ToString(); 58 weatherInfomation.TurismIndex = JObjtWeather["index_tr"].ToString(); 59 weatherInfomation.ComfortIndex = JObjtWeather["index_co"].ToString(); 60 weatherInfomation.MorningExerciseIndex = JObjtWeather["index_cl"].ToString(); 61 weatherInfomation.DryingIndex = JObjtWeather["index_ls"].ToString(); 62 weatherInfomation.AllergyIndex = JObjtWeather["index_ag"].ToString(); 63 } 64 catch(Exception e) 65 { 66 throw new FaultException<Exception>(e, e.Message); 67 } 68 return weatherInfomation; 69 }
1 View Code 2 /// <summary> 3 /// 根据给定中文星期返回英文星期名称 4 /// </summary> 5 /// <param name="week">中文星期</param> 6 /// <returns></returns> 7 private string GetWeekEn(string week) 8 { 9 switch (week) 10 { 11 case "星期一": 12 return "Monday"; 13 case "星期二": 14 return "Tuesday"; 15 case "星期三": 16 return "Wednesday"; 17 case "星期四": 18 return "Thursday"; 19 case "星期五": 20 return "Friday"; 21 case "星期六": 22 return "Saturday"; 23 case "星期天": 24 return "Sunday"; 25 } 26 return "Sunday"; 27 }
此功能依然是读取城市列表,返回所有已添加的城市,这样更加方便调用者
详细实现如下
1 View Code 2 /// <summary> 3 /// 根据IP返回IP所在城市 4 /// </summary> 5 /// <returns></returns> 6 public string GetCityName() 7 { 8 string url = ConfigurationManager.AppSettings["GetCityByIP"]; 9 WebClient wc = new WebClient(); 10 string cityJson = string.Empty; 11 string provincesAndCity = string.Empty; 12 string provinces = string.Empty; 13 string city = string.Empty; 14 try 15 { 16 cityJson = wc.DownloadString(url); 17 cityJson = cityJson.Replace("var returnCitySN = ", ""); 18 cityJson = cityJson.Replace(";", ""); 19 JObject JObjtCity = (JObject)JsonConvert.DeserializeObject(cityJson); 20 provincesAndCity = JObjtCity["cname"].ToString(); 21 22 provinces = provincesAndCity.Substring(0, provincesAndCity.IndexOf("省") + 1); 23 city = provincesAndCity.Substring(provincesAndCity.IndexOf("省") + 1); 24 } 25 catch (Exception) 26 { 27 throw new FaultException<Exception>(new Exception(), new Exception().Message); 28 } 29 return provincesAndCity; 30 }
四、附录
CityCode.Json.txt
View Code
{
"城市代码": [
{
"省": "北京",
"市": [
{
"市名": "北京",
"编码": "101010100"
},
{
"市名": "朝阳",
"编码": "101010300"
},
{
"市名": "顺义",
"编码": "101010400"
},
{
"市名": "怀柔",
"编码": "101010500"
},
{
"市名": "通州",
"编码": "101010600"
},
{
"市名": "昌平",
"编码": "101010700"
},
{
"市名": "延庆",
"编码": "101010800"
},
{
"市名": "丰台",
"编码": "101010900"
},
{
"市名": "石景山",
"编码": "101011000"
},
{
"市名": "大兴",
"编码": "101011100"
},
{
"市名": "房山",
"编码": "101011200"
},
{
"市名": "密云",
"编码": "101011300"
},
{
"市名": "门头沟",
"编码": "101011400"
},
{
"市名": "平谷",
"编码": "101011500"
},
{
"市名": "八达岭",
"编码": "101011600"
},
{
"市名": "佛爷顶",
"编码": "101011700"
},
{
"市名": "汤河口",
"编码": "101011800"
},
{
"市名": "密云上甸子",
"编码": "101011900"
},
{
"市名": "斋堂",
"编码": "101012000"
},
{
"市名": "霞云岭",
"编码": "101012100"
},
{
"市名": "北京城区",
"编码": "101012200"
},
{
"市名": "海淀",
"编码": "101010200"
}
]
},
{
"省": "天津",
"市": [
{
"市名": "天津",
"编码": "101030100"
},
{
"市名": "宝坻",
"编码": "101030300"
},
{
"市名": "东丽",
"编码": "101030400"
},
{
"市名": "西青",
"编码": "101030500"
},
{
"市名": "北辰",
"编码": "101030600"
},
{
"市名": "蓟县",
"编码": "101031400"
},
{
"市名": "汉沽",
"编码": "101030800"
},
{
"市名": "静海",
"编码": "101030900"
},
{
"市名": "津南",
"编码": "101031000"
},
{
"市名": "塘沽",
"编码": "101031100"
},
{
"市名": "大港",
"编码": "101031200"
},
{
"市名": "武清",
"编码": "101030200"
},
{
"市名": "宁河",
"编码": "101030700"
}
]
},
{
"省": "上海",
"市": [
{
"市名": "上海",
"编码": "101020100"
},
{
"市名": "宝山",
"编码": "101020300"
},
{
"市名": "嘉定",
"编码": "101020500"
},
{
"市名": "南汇",
"编码": "101020600"
},
{
"市名": "浦东",
"编码": "101021300"
},
{
"市名": "青浦",
"编码": "101020800"
},
{
"市名": "松江",
"编码": "101020900"
},
{
"市名": "奉贤",
"编码": "101021000"
},
{
"市名": "崇明",
"编码": "101021100"
},
{
"市名": "徐家汇",
"编码": "101021200"
},
{
"市名": "闵行",
"编码": "101020200"
},
{
"市名": "金山",
"编码": "101020700"
}
]
},
{
"省": "河北",
"市": [
{
"市名": "石家庄",
"编码": "101090101"
},
{
"市名": "张家口",
"编码": "101090301"
},
{
"市名": "承德",
"编码": "101090402"
},
{
"市名": "唐山",
"编码": "101090501"
},
{
"市名": "秦皇岛",
"编码": "101091101"
},
{
"市名": "沧州",
"编码": "101090701"
},
{
"市名": "衡水",
"编码": "101090801"
},
{
"市名": "邢台",
"编码": "101090901"
},
{
"市名": "邯郸",
"编码": "101091001"
},
{
"市名": "保定",
"编码": "101090201"
},
{
"市名": "廊坊",
"编码": "101090601"
}
]
},
{
"省": "河南",
"市": [
{
"市名": "郑州",
"编码": "101180101"
},
{
"市名": "新乡",
"编码": "101180301"
},
{
"市名": "许昌",
"编码": "101180401"
},
{
"市名": "平顶山",
"编码": "101180501"
},
{
"市名": "信阳",
"编码": "101180601"
},
{
"市名": "南阳",
"编码": "101180701"
},
{
"市名": "开封",
"编码": "101180801"
},
{
"市名": "洛阳",
"编码": "101180901"
},
{
"市名": "商丘",
"编码": "101181001"
},
{
"市名": "焦作",
"编码": "101181101"
},
{
"市名": "鹤壁",
"编码": "101181201"
},
{
"市名": "濮阳",
"编码": "101181301"
},
{
"市名": "周口",
"编码": "101181401"
},
{
"市名": "漯河",
"编码": "101181501"
},
{
"市名": "驻马店",
"编码": "101181601"
},
{
"市名": "三门峡",
"编码": "101181701"
},
{
"市名": "济源",
"编码": "101181801"
},
{
"市名": "安阳",
"编码": "101180201"
}
]
},
{
"省": "安徽",
"市": [
{
"市名": "合肥",
"编码": "101220101"
},
{
"市名": "芜湖",
"编码": "101220301"
},
{
"市名": "淮南",
"编码": "101220401"
},
{
"市名": "马鞍山",
"编码": "101220501"
},
{
"市名": "安庆",
"编码": "101220601"
},
{
"市名": "宿州",
"编码": "101220701"
},
{
"市名": "阜阳",
"编码": "101220801"
},
{
"市名": "亳州",
"编码": "101220901"
},
{
"市名": "黄山",
"编码": "101221001"
},
{
"市名": "滁州",
"编码": "101221101"
},
{
"市名": "淮北",
"编码": "101221201"
},
{
"市名": "铜陵",
"编码": "101221301"
},
{
"市名": "宣城",
"编码": "101221401"
},
{
"市名": "六安",
"编码": "101221501"
},
{
"市名": "巢湖",
"编码": "101221601"
},
{
"市名": "池州",
"编码": "101221701"
},
{
"市名": "蚌埠",
"编码": "101220201"
}
]
},
{
"省": "浙江",
"市": [
{
"市名": "杭州",
"编码": "101210101"
},
{
"市名": "舟山",
"编码": "101211101"
},
{
"市名": "湖州",
"编码": "101210201"
},
{
"市名": "嘉兴",
"编码": "101210301"
},
{
"市名": "金华",
"编码": "101210901"
},
{
"市名": "绍兴",
"编码": "101210501"
},
{
"市名": "台州",
"编码": "101210601"
},
{
"市名": "温州",
"编码": "101210701"
},
{
"市名": "丽水",
"编码": "101210801"
},
{
"市名": "衢州",
"编码": "101211001"
},
{
"市名": "宁波",
"编码": "101210401"
}
]
},
{
"省": "重庆",
"市": [
{
"市名": "重庆",
"编码": "101040100"
},
{
"市名": "合川",
"编码": "101040300"
},
{
"市名": "南川",
"编码": "101040400"
},
{
"市名": "江津",
"编码": "101040500"
},
{
"市名": "万盛",
"编码": "101040600"
},
{
"市名": "渝北",
"编码": "101040700"
},
{
"市名": "北碚",
"编码": "101040800"
},
{
"市名": "巴南",
"编码": "101040900"
},
{
"市名": "长寿",
"编码": "101041000"
},
{
"市名": "黔江",
"编码": "101041100"
},
{
"市名": "万州天城",
"编码": "101041200"
},
{
"市名": "万州龙宝",
"编码": "101041300"
},
{
"市名": "涪陵",
"编码": "101041400"
},
{
"市名": "开县",
"编码": "101041500"
},
{
"市名": "城口",
"编码": "101041600"
},
{
"市名": "云阳",
"编码": "101041700"
},
{
"市名": "巫溪",
"编码": "101041800"
},
{
"市名": "奉节",
"编码": "101041900"
},
{
"市名": "巫山",
"编码": "101042000"
},
{
"市名": "潼南",
"编码": "101042100"
},
{
"市名": "垫江",
"编码": "101042200"
},
{
"市名": "梁平",
"编码": "101042300"
},
{
"市名": "忠县",
"编码": "101042400"
},
{
"市名": "石柱",
"编码": "101042500"
},
{
"市名": "大足",
"编码": "101042600"
},
{
"市名": "荣昌",
"编码": "101042700"
},
{
"市名": "铜梁",
"编码": "101042800"
},
{
"市名": "璧山",
"编码": "101042900"
},
{
"市名": "丰都",
"编码": "101043000"
},
{
"市名": "武隆",
"编码": "101043100"
},
{
"市名": "彭水",
"编码": "101043200"
},
{
"市名": "綦江",
"编码": "101043300"
},
{
"市名": "酉阳",
"编码": "101043400"
},
{
"市名": "秀山",
"编码": "101043600"
},
{
"市名": "沙坪坝",
"编码": "101043700"
},
{
"市名": "永川",
"编码": "101040200"
}
]
},
{
"省": "福建",
"市": [
{
"市名": "福州",
"编码": "101230101"
},
{
"市名": "泉州",
"编码": "101230501"
},
{
"市名": "漳州",
"编码": "101230601"
},
{
"市名": "龙岩",
"编码": "101230701"
},
{
"市名": "晋江",
"编码": "101230509"
},
{
"市名": "南平",
"编码": "101230901"
},
{
"市名": "厦门",
"编码": "101230201"
},
{
"市名": "宁德",
"编码": "101230301"
},
{
"市名": "莆田",
"编码": "101230401"
},
{
"市名": "三明",
"编码": "101230801"
}
]
},
{
"省": "甘肃",
"市": [
{
"市名": "兰州",
"编码": "101160101"
},
{
"市名": "平凉",
"编码": "101160301"
},
{
"市名": "庆阳",
"编码": "101160401"
},
{
"市名": "武威",
"编码": "101160501"
},
{
"市名": "金昌",
"编码": "101160601"
},
{
"市名": "嘉峪关",
"编码": "101161401"
},
{
"市名": "酒泉",
"编码": "101160801"
},
{
"市名": "天水",
"编码": "101160901"
},
{
"市名": "武都",
"编码": "101161001"
},
{
"市名": "临夏",
"编码": "101161101"
},
{
"市名": "合作",
"编码": "101161201"
},
{
"市名": "白银",
"编码": "101161301"
},
{
"市名": "定西",
"编码": "101160201"
},
{
"市名": "张掖",
"编码": "101160701"
}
]
},
{
"省": "广东",
"市": [
{
"市名": "广州",
"编码": "101280101"
},
{
"市名": "惠州",
"编码": "101280301"
},
{
"市名": "梅州",
"编码": "101280401"
},
{
"市名": "汕头",
"编码": "101280501"
},
{
"市名": "深圳",
"编码": "101280601"
},
{
"市名": "珠海",
"编码": "101280701"
},
{
"市名": "佛山",
"编码": "101280800"
},
{
"市名": "肇庆",
"编码": "101280901"
},
{
"市名": "湛江",
"编码": "101281001"
},
{
"市名": "江门",
"编码": "101281101"
},
{
"市名": "河源",
"编码": "101281201"
},
{
"市名": "清远",
"编码": "101281301"
},
{
"市名": "云浮",
"编码": "101281401"
},
{
"市名": "潮州",
"编码": "101281501"
},
{
"市名": "东莞",
"编码": "101281601"
},
{
"市名": "中山",
"编码": "101281701"
},
{
"市名": "阳江",
"编码": "101281801"
},
{
"市名": "揭阳",
"编码": "101281901"
},
{
"市名": "茂名",
"编码": "101282001"
},
{
"市名": "汕尾",
"编码": "101282101"
},
{
"市名": "韶关",
"编码": "101280201"
}
]
},
{
"省": "广西",
"市": [
{
"市名": "南宁",
"编码": "101300101"
},
{
"市名": "柳州",
"编码": "101300301"
},
{
"市名": "来宾",
"编码": "101300401"
},
{
"市名": "桂林",
"编码": "101300501"
},
{
"市名": "梧州",
"编码": "101300601"
},
{
"市名": "防城港",
"编码": "101301401"
},
{
"市名": "贵港",
"编码": "101300801"
},
{
"市名": "玉林",
"编码": "101300901"
},
{
"市名": "百色",
"编码": "101301001"
},
{
"市名": "钦州",
"编码": "101301101"
},
{
"市名": "河池",
"编码": "101301201"
},
{
"市名": "北海",
"编码": "101301301"
},
{
"市名": "崇左",
"编码": "101300201"
},
{
"市名": "贺州",
"编码": "101300701"
}
]
},
{
"省": "贵州",
"市": [
{
"市名": "贵阳",
"编码": "101260101"
},
{
"市名": "安顺",
"编码": "101260301"
},
{
"市名": "都匀",
"编码": "101260401"
},
{
"市名": "兴义",
"编码": "101260906"
},
{
"市名": "铜仁",
"编码": "101260601"
},
{
"市名": "毕节",
"编码": "101260701"
},
{
"市名": "六盘水",
"编码": "101260801"
},
{
"市名": "遵义",
"编码": "101260201"
},
{
"市名": "凯里",
"编码": "101260501"
}
]
},
{
"省": "云南",
"市": [
{
"市名": "昆明",
"编码": "101290101"
},
{
"市名": "红河",
"编码": "101290301"
},
{
"市名": "文山",
"编码": "101290601"
},
{
"市名": "玉溪",
"编码": "101290701"
},
{
"市名": "楚雄",
"编码": "101290801"
},
{
"市名": "普洱",
"编码": "101290901"
},
{
"市名": "昭通",
"编码": "101291001"
},
{
"市名": "临沧",
"编码": "101291101"
},
{
"市名": "怒江",
"编码": "101291201"
},
{
"市名": "香格里拉",
"编码": "101291301"
},
{
"市名": "丽江",
"编码": "101291401"
},
{
"市名": "德宏",
"编码": "101291501"
},
{
"市名": "景洪",
"编码": "101291601"
},
{
"市名": "大理",
"编码": "101290201"
},
{
"市名": "曲靖",
"编码": "101290401"
},
{
"市名": "保山",
"编码": "101290501"
}
]
},
{
"省": "内蒙古",
"市": [
{
"市名": "呼和浩特",
"编码": "101080101"
},
{
"市名": "乌海",
"编码": "101080301"
},
{
"市名": "集宁",
"编码": "101080401"
},
{
"市名": "通辽",
"编码": "101080501"
},
{
"市名": "阿拉善左旗",
"编码": "101081201"
},
{
"市名": "鄂尔多斯",
"编码": "101080701"
},
{
"市名": "临河",
"编码": "101080801"
},
{
"市名": "锡林浩特",
"编码": "101080901"
},
{
"市名": "呼伦贝尔",
"编码": "101081000"
},
{
"市名": "乌兰浩特",
"编码": "101081101"
},
{
"市名": "包头",
"编码": "101080201"
},
{
"市名": "赤峰",
"编码": "101080601"
}
]
},
{
"省": "江西",
"市": [
{
"市名": "南昌",
"编码": "101240101"
},
{
"市名": "上饶",
"编码": "101240301"
},
{
"市名": "抚州",
"编码": "101240401"
},
{
"市名": "宜春",
"编码": "101240501"
},
{
"市名": "鹰潭",
"编码": "101241101"
},
{
"市名": "赣州",
"编码": "101240701"
},
{
"市名": "景德镇",
"编码": "101240801"
},
{
"市名": "萍乡",
"编码": "101240901"
},
{
"市名": "新余",
"编码": "101241001"
},
{
"市名": "九江",
"编码": "101240201"
},
{
"市名": "吉安",
"编码": "101240601"
}
]
},
{
"省": "湖北",
"市": [
{
"市名": "武汉",
"编码": "101200101"
},
{
"市名": "黄冈",
"编码": "101200501"
},
{
"市名": "荆州",
"编码": "101200801"
},
{
"市名": "宜昌",
"编码": "101200901"
},
{
"市名": "恩施",
"编码": "101201001"
},
{
"市名": "十堰",
"编码": "101201101"
},
{
"市名": "神农架",
"编码": "101201201"
},
{
"市名": "随州",
"编码": "101201301"
},
{
"市名": "荆门",
"编码": "101201401"
},
{
"市名": "天门",
"编码": "101201501"
},
{
"市名": "仙桃",
"编码": "101201601"
},
{
"市名": "潜江",
"编码": "101201701"
},
{
"市名": "襄樊",
"编码": "101200201"
},
{
"市名": "鄂州",
"编码": "101200301"
},
{
"市名": "孝感",
"编码": "101200401"
},
{
"市名": "黄石",
"编码": "101200601"
},
{
"市名": "咸宁",
"编码": "101200701"
}
]
},
{
"省": "四川",
"市": [
{
"市名": "成都",
"编码": "101270101"
},
{
"市名": "自贡",
"编码": "101270301"
},
{
"市名": "绵阳",
"编码": "101270401"
},
{
"市名": "南充",
"编码": "101270501"
},
{
"市名": "达州",
"编码": "101270601"
},
{
"市名": "遂宁",
"编码": "101270701"
},
{
"市名": "广安",
"编码": "101270801"
},
{
"市名": "巴中",
"编码": "101270901"
},
{
"市名": "泸州",
"编码": "101271001"
},
{
"市名": "宜宾",
"编码": "101271101"
},
{
"市名": "内江",
"编码": "101271201"
},
{
"市名": "资阳",
"编码": "101271301"
},
{
"市名": "乐山",
"编码": "101271401"
},
{
"市名": "眉山",
"编码": "101271501"
},
{
"市名": "凉山",
"编码": "101271601"
},
{
"市名": "雅安",
"编码": "101271701"
},
{
"市名": "甘孜",
"编码": "101271801"
},
{
"市名": "阿坝",
"编码": "101271901"
},
{
"市名": "德阳",
"编码": "101272001"
},
{
"市名": "广元",
"编码": "101272101"
},
{
"市名": "攀枝花",
"编码": "101270201"
}
]
},
{
"省": "宁夏",
"市": [
{
"市名": "银川",
"编码": "101170101"
},
{
"市名": "中卫",
"编码": "101170501"
},
{
"市名": "固原",
"编码": "101170401"
},
{
"市名": "石嘴山",
"编码": "101170201"
},
{
"市名": "吴忠",
"编码": "101170301"
}
]
},
{
"省": "青海",
"市": [
{
"市名": "西宁",
"编码": "101150101"
},
{
"市名": "黄南",
"编码": "101150301"
},
{
"市名": "海北",
"编码": "101150801"
},
{
"市名": "果洛",
"编码": "101150501"
},
{
"市名": "玉树",
"编码": "101150601"
},
{
"市名": "海西",
"编码": "101150701"
},
{
"市名": "海东",
"编码": "101150201"
},
{
"市名": "海南",
"编码": "101150401"
}
]
},
{
"省": "山东",
"市": [
{
"市名": "济南",
"编码": "101120101"
},
{
"市名": "潍坊",
"编码": "101120601"
},
{
"市名": "临沂",
"编码": "101120901"
},
{
"市名": "菏泽",
"编码": "101121001"
},
{
"市名": "滨州",
"编码": "101121101"
},
{
"市名": "东营",
"编码": "101121201"
},
{
"市名": "威海",
"编码": "101121301"
},
{
"市名": "枣庄",
"编码": "101121401"
},
{
"市名": "日照",
"编码": "101121501"
},
{
"市名": "莱芜",
"编码": "101121601"
},
{
"市名": "聊城",
"编码": "101121701"
},
{
"市名": "青岛",
"编码": "101120201"
},
{
"市名": "淄博",
"编码": "101120301"
},
{
"市名": "德州",
"编码": "101120401"
},
{
"市名": "烟台",
"编码": "101120501"
},
{
"市名": "济宁",
"编码": "101120701"
},
{
"市名": "泰安",
"编码": "101120801"
}
]
},
{
"省": "陕西",
"市": [
{
"市名": "西安",
"编码": "101110101"
},
{
"市名": "延安",
"编码": "101110300"
},
{
"市名": "榆林",
"编码": "101110401"
},
{
"市名": "铜川",
"编码": "101111001"
},
{
"市名": "商洛",
"编码": "101110601"
},
{
"市名": "安康",
"编码": "101110701"
},
{
"市名": "汉中",
"编码": "101110801"
},
{
"市名": "宝鸡",
"编码": "101110901"
},
{
"市名": "咸阳",
"编码": "101110200"
},
{
"市名": "渭南",
"编码": "101110501"
}
]
},
{
"省": "山西",
"市": [
{
"市名": "太原",
"编码": "101100101"
},
{
"市名": "临汾",
"编码": "101100701"
},
{
"市名": "运城",
"编码": "101100801"
},
{
"市名": "朔州",
"编码": "101100901"
},
{
"市名": "忻州",
"编码": "101101001"
},
{
"市名": "长治",
"编码": "101100501"
},
{
"市名": "大同",
"编码": "101100201"
},
{
"市名": "阳泉",
"编码": "101100301"
},
{
"市名": "晋中",
"编码": "101100401"
},
{
"市名": "晋城",
"编码": "101100601"
},
{
"市名": "吕梁",
"编码": "101101100"
}
]
},
{
"省": "新疆",
"市": [
{
"市名": "乌鲁木齐",
"编码": "101130101"
},
{
"市名": "石河子",
"编码": "101130301"
},
{
"市名": "昌吉",
"编码": "101130401"
},
{
"市名": "吐鲁番",
"编码": "101130501"
},
{
"市名": "库尔勒",
"编码": "101130601"
},
{
"市名": "阿拉尔",
"编码": "101130701"
},
{
"市名": "阿克苏",
"编码": "101130801"
},
{
"市名": "喀什",
"编码": "101130901"
},
{
"市名": "伊宁",
"编码": "101131001"
},
{
"市名": "塔城",
"编码": "101131101"
},
{
"市名": "哈密",
"编码": "101131201"
},
{
"市名": "和田",
"编码": "101131301"
},
{
"市名": "阿勒泰",
"编码": "101131401"
},
{
"市名": "阿图什",
"编码": "101131501"
},
{
"市名": "博乐",
"编码": "101131601"
},
{
"市名": "克拉玛依",
"编码": "101130201"
}
]
},
{
"省": "西藏",
"市": [
{
"市名": "拉萨",
"编码": "101140101"
},
{
"市名": "山南",
"编码": "101140301"
},
{
"市名": "阿里",
"编码": "101140701"
},
{
"市名": "昌都",
"编码": "101140501"
},
{
"市名": "那曲",
"编码": "101140601"
},
{
"市名": "日喀则",
"编码": "101140201"
},
{
"市名": "林芝",
"编码": "101140401"
}
]
},
{
"省": "台湾",
"市": [
{
"市名": "台北县",
"编码": "101340101"
},
{
"市名": "高雄",
"编码": "101340201"
},
{
"市名": "台中",
"编码": "101340401"
}
]
},
{
"省": "海南",
"市": [
{
"市名": "海口",
"编码": "101310101"
},
{
"市名": "三亚",
"编码": "101310201"
},
{
"市名": "东方",
"编码": "101310202"
},
{
"市名": "临高",
"编码": "101310203"
},
{
"市名": "澄迈",
"编码": "101310204"
},
{
"市名": "儋州",
"编码": "101310205"
},
{
"市名": "昌江",
"编码": "101310206"
},
{
"市名": "白沙",
"编码": "101310207"
},
{
"市名": "琼中",
"编码": "101310208"
},
{
"市名": "定安",
"编码": "101310209"
},
{
"市名": "屯昌",
"编码": "101310210"
},
{
"市名": "琼海",
"编码": "101310211"
},
{
"市名": "文昌",
"编码": "101310212"
},
{
"市名": "保亭",
"编码": "101310214"
},
{
"市名": "万宁",
"编码": "101310215"
},
{
"市名": "陵水",
"编码": "101310216"
},
{
"市名": "西沙",
"编码": "101310217"
},
{
"市名": "南沙岛",
"编码": "101310220"
},
{
"市名": "乐东",
"编码": "101310221"
},
{
"市名": "五指山",
"编码": "101310222"
},
{
"市名": "琼山",
"编码": "101310102"
}
]
},
{
"省": "湖南",
"市": [
{
"市名": "长沙",
"编码": "101250101"
},
{
"市名": "株洲",
"编码": "101250301"
},
{
"市名": "衡阳",
"编码": "101250401"
},
{
"市名": "郴州",
"编码": "101250501"
},
{
"市名": "常德",
"编码": "101250601"
},
{
"市名": "益阳",
"编码": "101250700"
},
{
"市名": "娄底",
"编码": "101250801"
},
{
"市名": "邵阳",
"编码": "101250901"
},
{
"市名": "岳阳",
"编码": "101251001"
},
{
"市名": "张家界",
"编码": "101251101"
},
{
"市名": "怀化",
"编码": "101251201"
},
{
"市名": "黔阳",
"编码": "101251301"
},
{
"市名": "永州",
"编码": "101251401"
},
{
"市名": "吉首",
"编码": "101251501"
},
{
"市名": "湘潭",
"编码": "101250201"
}
]
},
{
"省": "江苏",
"市": [
{
"市名": "南京",
"编码": "101190101"
},
{
"市名": "镇江",
"编码": "101190301"
},
{
"市名": "苏州",
"编码": "101190401"
},
{
"市名": "南通",
"编码": "101190501"
},
{
"市名": "扬州",
"编码": "101190601"
},
{
"市名": "宿迁",
"编码": "101191301"
},
{
"市名": "徐州",
"编码": "101190801"
},
{
"市名": "淮安",
"编码": "101190901"
},
{
"市名": "连云港",
"编码": "101191001"
},
{
"市名": "常州",
"编码": "101191101"
},
{
"市名": "泰州",
"编码": "101191201"
},
{
"市名": "无锡",
"编码": "101190201"
},
{
"市名": "盐城",
"编码": "101190701"
}
]
},
{
"省": "黑龙江",
"市": [
{
"市名": "哈尔滨",
"编码": "101050101"
},
{
"市名": "牡丹江",
"编码": "101050301"
},
{
"市名": "佳木斯",
"编码": "101050401"
},
{
"市名": "绥化",
"编码": "101050501"
},
{
"市名": "黑河",
"编码": "101050601"
},
{
"市名": "双鸭山",
"编码": "101051301"
},
{
"市名": "伊春",
"编码": "101050801"
},
{
"市名": "大庆",
"编码": "101050901"
},
{
"市名": "七台河",
"编码": "101051002"
},
{
"市名": "鸡西",
"编码": "101051101"
},
{
"市名": "鹤岗",
"编码": "101051201"
},
{
"市名": "齐齐哈尔",
"编码": "101050201"
},
{
"市名": "大兴安岭",
"编码": "101050701"
}
]
},
{
"省": "吉林",
"市": [
{
"市名": "长春",
"编码": "101060101"
},
{
"市名": "延吉",
"编码": "101060301"
},
{
"市名": "四平",
"编码": "101060401"
},
{
"市名": "白山",
"编码": "101060901"
},
{
"市名": "白城",
"编码": "101060601"
},
{
"市名": "辽源",
"编码": "101060701"
},
{
"市名": "松原",
"编码": "101060801"
},
{
"市名": "吉林",
"编码": "101060201"
},
{
"市名": "通化",
"编码": "101060501"
}
]
},
{
"省": "辽宁",
"市": [
{
"市名": "沈阳",
"编码": "101070101"
},
{
"市名": "鞍山",
"编码": "101070301"
},
{
"市名": "抚顺",
"编码": "101070401"
},
{
"市名": "本溪",
"编码": "101070501"
},
{
"市名": "丹东",
"编码": "101070601"
},
{
"市名": "葫芦岛",
"编码": "101071401"
},
{
"市名": "营口",
"编码": "101070801"
},
{
"市名": "阜新",
"编码": "101070901"
},
{
"市名": "辽阳",
"编码": "101071001"
},
{
"市名": "铁岭",
"编码": "101071101"
},
{
"市名": "朝阳",
"编码": "101071201"
},
{
"市名": "盘锦",
"编码": "101071301"
},
{
"市名": "大连",
"编码": "101070201"
},
{
"市名": "锦州",
"编码": "101070701"
}
]
}
]
}
2、天气WCF服务

浙公网安备 33010602011771号