Web service test-Weather Forecast

Source: Internet
Author: User
  • Web status quo
  • Web Services
    • Concept
    • With Web Services
    • Composition
    • UDDI
    • WSDL
  • Weather Forecast
Web service status quoI used to introduce WSDL when I read VB. NET. Now I have learned web services, so I will take a look at the weather forecast instance. Before let's go talks about Web Services, let's talk about why Web services are generated. After all, "existence is reasonable" and the Internet is as follows:
Each web server exists independently, as if it is an isolated island and has no interaction. Web services are generated to enhance interaction between them. What is a service?Web service is a service based on XML and HTTPS. Its communication protocol is mainly based on soap. The service description uses WSDL to discover and obtain service metadata through UDDI. A Web Service is an application that exposes an API that can be called through the Web and can be called through the Web through programming.
Simple Web server interaction is rare. What about Web Services? It can be seen that the interactions between servers in the network with Web services have increased significantly. What are the components of Web Services? Web service composition UDDI and WSDL.UDDI: "Universal Description, discovery and Integration", which can be translated as "general description, discovery and integration service". This is a directory service, you can use it to register and search Web Services. In other words, if you want to publish a network service, register it now. If you want to use the service, you can search for it here. Wdsl: "Web Services Description Language", a Web service description language, is an XML language used to describe Web Services and describe how to communicate with Web services. It provides you with a detailed interface description. Weather Forecast We use the webxml.com.cn weather forecast Web Service. The data comes from the weather forecast data of more than 340 major Chinese cities and more than 60 major foreign cities within three days. The service address is http://www.webxml.com.cn/webservices/weatherwebservice.asmx.
Web service please note or link this site: http://www.webxml.com.cn/Thank you for your support! Service method:Getsupportcity: query the information of domestic and foreign cities or regions supported by the weather forecast Web Services. input the parameter byprovincename = Specified continent or Chinese province. If it is all or empty, all cities are returned; returned data: A one-dimensional string (), with the structure: city name (city code ).
Getsuppdatasdataset: obtain information about continents, provinces, and cities supported by the weather forecast Web Services. input the parameter: none; Return: Dataset. Dataset. tables (0) is the data of supported continents and provinces in China, dataset. tables (1) is the data of domestic and foreign cities or regions supported, dataset. tables (0 ). rows (I ). item ("ID") primary key corresponds to dataset. tables (1 ). rows (I ). item ("zoneid") foreign key. Tables (0): Id = id Primary Key, zone = supported continents and provinces; Tables (1): ID
Primary Key. zoneid = specifies the foreign key corresponding to tables (0) ID. Area = city or region, and areacode = city or region code.
Getsupportprovince: obtain information about continents, provinces, and cities supported by the weather forecast Web Services. input parameter: none; return data: A one-dimensional string array string (), the content is the name of a continent or a Chinese province.
Getweatherbycityname: Obtain the weather conditions, current weather conditions, weather and life indexes in the next three days based on the city or region name. The call method is as follows: enter a parameter: thecityname = Chinese city name (available in English for foreign cities) or city code (the default value is Shanghai if not entered), for example, Shanghai or 58367, if a city name already exists, use the city code to query the data (obtained through getsupportcity or getsupportdataset). The returned data is a one-dimensional array string (22) with 23 Elements in total. String (0) to string (4): province, city, city code, city image name, last update time. String (5)
To string (11): the temperature, Overview, wind direction, and wind power of the day, the name of the image showing the start of the weather trend (image 1), and the name of the image showing the ending of the weather trend (hereinafter referred to: icon 2), current weather conditions, weather and life indexes. String (12) to string (16): the next day's temperature, Overview, wind direction and wind power, MAP 1, Icon 2. String (17) to string (21): the temperature, Overview, wind direction, and wind power on the third day. For example 1 and 2. String (22) Description of the city or region to be queried

Download the weather icon (including large, medium, and small sizes) weather legend. Call this weather forecast Web Services instance download (VB Asp.net 2.0)
Getweatherbycitynamepro: obtains the weather conditions, current weather conditions, weather and life indexes (for commercial users) in the next three days based on the city or region name. The call method is the same as getweatherbycityname. Enter the parameter: theuserid = Business User ID WSDLSome wdsl are as follows:
<WSDL: porttype name = "weatherwebservicehttpget"> <WSDL: Operation name = "getsupportcity"> <WSDL: Documentation xmlns: WSDL = "http://schemas.xmlsoap.org/wsdl/"> <br/> 

Use Services1. Obtain and reference services: solution manager --- app_webreferences --- add web references --- enter "http://www.webxml.com.cn/webservices/weatherwebservice.asmx#---: 2. Background code:

Protected void page_load (Object sender, eventargs e) {cn.com. webxml. www. weatherwebservice cnweather = new cn.com. webxml. www. weatherwebservice (); // instantiate the service string [] weather = cnweather. getweatherbycityname ("Langfang"); // obtain the weather information txttemp Based on the city name. TEXT = weather [5]; // temperature txtsurvey. TEXT = weather [6]; // overview txtwinddirection. TEXT = weather [7]; // wind power}
3. Running result: This article only demonstrates the simple weather forecast, which has more features: wind direction, wind power, index, live status, and the next three days with colorful pictures, waiting for everyone to develop.

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.