Using wsimport and wsgen Tools

Author: Tatyana Milkina

Difference between wsimport and wsgen

The wsimport utility is used to generate Java client artifacts from the WSDL document and wsgen - for generating required files for web service deployment.

Wsimport

The utility generates:

  • Service Endpoint Interface
  • Service
  • Exception class mapped
  • Async Reponse Bean
  • JAXB generated value types

To receive a report on how to use the utility, run the command at a command prompt:

% wsimport

Example of using wsimport

It is required to create a client for http://YOUR-HOST/ws1-1.0-SNAPSHOT/ExamClouds service. Run the next command in the command prompt:

wsimport -s src/main/java -p example.client
http://YOUR_HOST/ws1-1.0-SNAPSHOT/ExamClouds?wsdl

The option –s specifies the place of generated source code files. The option –p is used to specify a target package. See the full example of SOAP RPC Web Service in Java.

Wsgen

The wsgen utility generates:

  • JAXB classes;
  • WSDL file if -wsdl option is specified.

The wsgen tool is optional in Java EE6 because artifacts are generated at run time.

To receive a report on how to use the utility, run the command at a command prompt:

% wsgen

Example of generating a WSDL document

% wsgen -cp "." -wsdl ch01.es.ExamServerImpl

Example of generating artifacts

% wsgen -keep -cp . ch01.ts.TimeServerImpl
Курс 'Java для начинающих' на Udemy Курс 'Java для начинающих' на Udemy
Комментарии