WebService Learning to organize the difference and use of WSDL2JAVA commands of-JDK wsimport commands and CXF

Source: Internet
Author: User
Tags wsdl

As the project is serviced, the use of WebService is common in some large projects, and here are two ways to generate client code based on the service address provided.

Note: You need to configure the environment variables when using both of these methods. CXF Configuration and JDK configuration is roughly the same, here is not explained, not configured a good Baidu.

(1) The JDK provides a wsimport.exe command that is used to generate client code for WebService and then invoke WebService.

Wsimport is based on jdk1.6.0_21 and above the generated local code, it can only resolve the server-side SOAP protocol is 1.1, can not resolve the SOAP1.2 protocol. If parsing SOAP1.2 will parse incomplete.
Syntax: wsimport-s file Address-P custom class package URL path
-S to specify the path to the build file, the-P custom class package URL is http://localhost:8888/hello?wsdl is the path to the WSDL
Usage: JDK configuration for PATH environment variable c:\aflyun>wsimport-s f:\-P com.aflyun.client.jdk.wsimporthttp://localhost:8888/hello?wsdl

(2) CXF provides the Wsdl2java.exe command to generate client code, and then invoke WebService.

Wsdl2java is a command provided by CXF to generate client code based on WSDL. It is based on the local code generated by jdk1.7, so you need to make a little change to the generated code.
It can support the SOAP1.1 and SOAP1.2 protocols. The premise is that you have already downloaded the Apache CXF and configured the Wsdl2java.exe for the PATH environment variable.
Syntax: wsdl2java-d file Address-P custom class package URL path

-d Specifies the path to the build file, and the-P custom class package  http://localhost:8888/hello?wsdl is the path to the WSDL.
Usage: c:\aflyun>wsdl2java-d f:\-P com.aflyun.client.cxf http://localhost:8888/hello?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.