Generating Java code using IDEA and WSDL

Source: Internet
Author: User

    1. Create a simple Java HelloWorld project

Select Next:

Select Java HelloWorld Project Next

Fill out project name finish

2. After creating the project, select the project right click->webservice->generate

Generate code configuration, fill in the WSDL path, package path, WebService platform (I chose the Jax-ws JDK to bring the webservice implementation, no longer download the jar package)

Here I use the WSDL, which is a webservice:http://www.webservicex.com/globalweather.asmx?wsdl of the weather forecast

Select Finish to wait a moment to see the generated code:

3. Test code

Fill in the following code in main class

Import weather. Globalweather;import weather. Globalweathersoap;public class Main {public static void Main (string[] args) {Globalweather service = new Globa        Lweather ();        Globalweathersoap port = Service.getglobalweathersoap ();        String BODY = port.getweather ("Shanghai", "China");    System.out.println (body); }}

The results of the operation are as follows:

<?xml version= "1.0"  encoding= "utf-16"?><currentweather>  <location> shanghai / hongqiao, china  (ZSSS)  31-10N 121-26E 3M</Location>   <time>jul 22, 2015 - 12:00 am edt / 2015.07.22 0400  UTC</Time>  <Wind> Variable at 2 MPH  (2 kt): 0</ Wind>  <visibility> greater than 7 mile (s):0</Visibility>   <SkyConditions> mostly clear</SkyConditions>  <Temperature>  84 f  (29 c) </Temperature>  <DewPoint> 78 F  (26 c) < /dewpoint>  <relativehumidity> 83%</relativehumidity>  <pressure > 29.65 in. Hg  (1004&NBSP;HPA) </pressure>  <status>success</ Status></currentweatheR> 

Build the platform framework for your code, or you can choose axis, CXF,

Generating Java code using IDEA and WSDL

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.