How to Run wsgen and wsimport in JAX-WS Web Services

By Arvind Rai, November 17, 2013
wsgen and wsimport are the tools for JAX-WS web services that generates artifacts. These artifacts helps for deployment and invocation of JAX-WS web services. To generates artifacts, wsgen reads end point of web services and generates the required class files. Wsimport accesses the wsdl URL and generates the required class files for web service client.

How to Run wsgen

To run wsgen, we need to set java path. In java bin, there is wsgen.sh for linux and wsgen.bat for windows.
To run the command, go to the root directory of web services project and use the below command on the command prompt.

wsgen -cp bin -d bin -s src/main/java com.concretepage.endpoint.WelcomeImpl

-d : -d option specifies the directory from where wsgen gets the generated output files.
-cp : -cp specifies the directory from where wsgen gets input class files. In our example input and output both is bin directory.
-s: -s generates source files in the specified directory. In our example src/main/java is the source file directory.

For the web service end point WelcomeImpl class, below class will be generated.
GetWelcomeMsg.class
GetWelcomeMsgResponse.class

How to Run wsgen and wsimport in JAX-WS Web Services

How to Run wsimport

To run the wsimport, java path must be set. wsimport.bat or wsimport.sh can be found in java bin directory. wsimport is used with web services client. To generate supporting classes of web services end point, wsimport is used. To run the wsimport , go to the root directory of web services client project and use command prompt.

wsimport -s src/main/java http://localhost:8080/WebServiceDemo/Welcome?wsdl

-s -s defines the directory for source files.
And pass the wsdl URL of web services end point.

The below classes will be generated for web service client for the given WSDL URL.

GetWelcomeMsg.class
GetWelcomeMsgResponse.class
ObjectFactory.class
package-info.class
Welcome.class
WelcomeImplService.class

How to Run wsgen and wsimport in JAX-WS Web Services
POSTED BY
ARVIND RAI
ARVIND RAI







©2024 concretepage.com | Privacy Policy | Contact Us