webservice generates Java code from wsdl

The general way to call webservice:
1. Generate code codes
from the wsdl document and then call; 2. Remotely call through the url of the wsdl document;
reference: WebService technical details (1)

Let’s talk about the first way to call through wsdl to generate code:
1. You can use wsdl to generate code through the idea editor.
Reference:
idea to build a WebService HelloWorld program

2. Use the Apache CXF tool to generate the code and then call the wsdl:
1. Download the generation tool Apache CXF from the official website
(or Baidu Cloud: link: https://pan.baidu.com/s/1z5xyyVJhCuPEGqs0q_ZHqA
extraction code: g3zk)

2. Unzip the compressed package and
set the system environment variables
a) Variable name: CXF_HOME
b) Variable value: Unzip directory
Insert picture description here
c) Variable name: Path
d) Variable value: %CXF_HOME%\bin

Insert picture description here
3. cmd to enter the dos command window
a) input wsdl2java -v view the version proved configuration environment variable to take effect

Insert picture description here

4. Usage of wsdl2java:
a) wsdl2java -p com -d src -all wsdl
b) Parameter description
i. -p specifies the namespace of its wsdl, that is, the package name of the code to be generated
ii. -d specifies the directory where the code is to be generated
iii. -all generates all codes

c) Examples

wsdl2java -p com.test.client -d D:\wsdl -all http://localhost:8080/WebService_war_exploded/services/HelloWorld?wsdl

Note: The wsdl of
http://localhost:8080/WebService_war_exploded/services/HelloWorld?wsdl will be generated in the wsdl folder of D drive to generate Java code, com.test.client is the package name in the code.

Then copy the generated code to the com.test.client folder of the project to call it.

Reference:
How to correctly choose between Axis, Axis2 and Apache CXF?
Several popular open source WebService frameworks Axis1, Axis2, Xfire, CXF, JWS compare
ideas to build a WebService HelloWorld program

Guess you like

Origin blog.csdn.net/qq_33697094/article/details/110180379