Use WebService of the National Meteorological Administration to query weather forecasts

Source: Internet
Author: User

Original article address

Weather Forecast for WebService query:
Obtain the weather conditions, current weather conditions, weather and life indexes in the next three days based on the city or region name query.
First, we will first use a prepared weather forecast of the WebService Service, WebService Service from webxml, free, and query information from the National Meteorological Administration, address: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx? WSDL

You can try to open the above connection in the browser, and you will see the WSDL document description of the XML structure returned in the browser. From this, you can find such code:

<S: element name = "getweatherbycityname">
<S: complextype>
<S: sequence>
<S: Element minoccurs = "0" maxoccurs = "1" name = "thecityname" type = "s: string"/>
</S: sequence>
</S: complextype>
</S: Element>
Specifically, getweatherbycityname is the function name that requests ws to return the weather forecast of a specific city, and thecityname is the parameter of the city name (in fact, you only need to pass the valid city name to getweatherbycityname in string format. As for which city is listed in Its WebService Service, you can discover WebService by yourself
Next, you can visit here to further test this WebService, and you can see the XML data returned by the city weather forecast before writing the code, standard Request and response examples of soap1.1 and 1.2, including http get and post examples. If the input city is "Beijing", you will get data in XML format.

Http://www.webxml.com.cn/WebServices/WeatherWebService.asmx? OP = getweatherbycityname

<Arrayofstring>
<String> municipalities </string>
<String> Beijing </string>
<String> 54511 </string>
<String> 54511.jpg</string>
<String> 15:14:50 </string>
<String> 4 ℃/-6 ℃ </string>
<String> February 20 clear to cloudy </string>
<String> breeze </string>
<String> 0.gif</string>
<String> 1.gif</string>
<String> today's weather conditions:; 1 ℃; wind direction/wind power: South Wind 3; air quality: moderate; ultraviolet intensity: weak </string>
<String>
Dressing Index: The weather is cold. We recommend that you wear winter clothes such as cotton clothing, leather jackets, and sweaters. A thick cotton coat or a winter coat is recommended for the elderly and the weak.
Cold index: the temperature difference between day and night is large and it is easy to catch a cold. Please increase or decrease your clothes as appropriate. If you are physically weak, pay attention to protection.
Morning exercise index: The weather is fine and the air is fresh. It is a great time for you to perform morning exercises. We recommend that people of different ages actively participate in outdoor fitness activities.
Traffic index: the weather is fine, the road surface is dry, and the traffic and weather conditions are good. The vehicle can drive normally.
Heatstroke index: the temperature is not high, other meteorological conditions are suitable, and the chance of heatstroke is very low.
Park index: the weather is cold and it is not suitable for flying a kite.
Sunscreen index: the intensity of ultraviolet rays is weak. It is recommended that SPF be rubbed between 12-15 and PA + Sunscreen skin care products.
Travel index: sunny days, cold days, and windy weather. The travel index is average. You can wear more clothes when you are out to avoid catching a cold!
</String>
<String> 7 ℃/-3 ℃ </string>
<String> cloudy in February 21 </string>
<String> breeze </string>
<String> 1.gif</string>
<String> 1.gif</string>
<String> 4 ℃/-6 ℃ </string>
<String> cloudy in February 22 </string>
<String> breeze </string>
<String> 1.gif</string>
<String> 1.gif</string>
<String>
Beijing is located at the northwest edge of the North China Plain, with the city center at 39 degrees north latitude and 116 degrees east longitude. It is surrounded by Hebei Province and connected to Tianjin in the southeast. The city covers more than sixteen thousand square kilometers and covers 12 districts and 6 counties with a population of more than 1100. Beijing is a warm and semi-humid continental monsoon climate. It is hot and rainy in summer, cold and dry in winter, short promotion in spring and autumn, and the average annual temperature is 10-12 degrees Celsius.
Beijing is one of the world's famous historical and cultural cities and ancient capitals. As early as 0.7 million years ago, people from Beijing appeared in the Zhoukoudian area of Beijing ". Beijing has a history of more than two thousand years. It was originally recorded as "Ji ". In 1045 BC, Beijing became the capital city of zhuhou countries such as JI and Yan. Since the reunification of China by Qin Shihuang in 221 BC, Beijing has always been the important town and local center in North China. Since 938 AD, beijing has successively become the capital of the Liao, beidu, jindu, yuandu, and Ming and Qing dynasties. January 1, October 1, 1949 was officially set as the capital of the People's Republic of China.
Beijing has abundant tourism resources and more than 200 open tourist attractions. There are the largest palace in the world, the Forbidden City, the Temple of Heaven, the royal garden Beihai, and the Royal Garden Summer Palace, there are also various monuments such as Badaling, mutianyu, simatai Great Wall, and gongwangfu, the world's largest siheyuan. There are a total of 7309 cultural relics and monuments in the city, including 42 national cultural relics protection units and 222 municipal cultural relics protection units. The city trees in Beijing are Huai and cypress, and the City Flowers are rose and chrysanthemum. In addition, traditional handicrafts such as ivory carvings, jade carvings, cloisonne, and carpets produced in Beijing are well known in the world.
</String>
</Arrayofstring>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.