Java uses the. NET WebService

Source: Internet
Author: User

1. Download the latest Axis2

Http://mirrors.hust.edu.cn/apache//axis/axis2/java/core/1.6.3/axis2-1.6.3-bin.zip

2. Unzip the switch to Bin using DOS, execute

Wsdl2java.bat-uri http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl

This is a weather forecast service written in. Net. SRC was generated later in the bin.

3. Copy the SRC code into a Java project and copy the jar from the Lib in axis to the project.

4. Create a new class, Test.java

 PackageCn.com.webxml;Importcn.com.webxml.WeatherWebServiceStub.ArrayOfString;ImportCn.com.webxml.WeatherWebServiceStub.GetWeatherbyCityName; Public classTest { Public Static voidMain (string[] args)throwsexception{weatherwebservicestub stub=Newweatherwebservicestub (); Stub._getserviceclient (). GetOptions (). SetProperty (Org.apache.axis2.transport.http.HTTPConstants.CHUNKE                 D, Boolean.false); Getweatherbycityname City=NewGetweatherbycityname (); City.setthecityname (Shenzhen); Arrayofstring Array=Stub.getweatherbycityname (city). Getgetweatherbycitynameresult (); string[] Str=array.getstring ();  for(String s:str) {System.out.println (s); }      }}

5. Run test with the following results:

Guangdong
Shenzhen
59493
59493.jpg
2015-10-10 8:15:46
21℃/28℃
October 10 Cloudy
No continuous wind Breeze
1.gif
1.gif
Today's weather: temperature: 23 ℃; Wind/Wind: 2 Levels in the northeast, Humidity: 69%; Air quality: temporarily no; UV intensity: weak
Sunglasses index: not required. Daytime light is weak and no sunglasses are required.
Dressing index: Hot. Suitable for summer wear such as T-shirts and short coats.
Tourism index: suitable. Have rain, enjoy the fun of traveling in the rains to carry rain gear.
Movement Index: more unfavorable. There is precipitation, it is recommended that you indoor leisure sports.
Car Wash Index: not appropriate. Rain, rain and mud will stain your car.
Makeup index: Go oil. Please choose the dew cream to make the bottom, the water quality oil-free Foundation cream.
Cold index: more prone to hair. The weather is cool, the humidity is big, easy cold.
Air Pollution index: not currently.
UV index: weak. The radiation is weak, rub spf12-15, pa+ skin care product.
Comfort Index: more comfortable. Rain in the daytime, some heat.

......

Java uses the. NET WebService

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.