-
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