How to parse a WSDL file using 'wsimport' tool and generate java classes?
The Web Services Description Language (WSDL) is an XML based interface definition language that is used for describing the functionality offered by a SOAP web service. If you would like to parse a WSDL file to generate java classes, you can use the wsimport tool. This 'wsimport' tool comes with the JDK (Java Development Kit) and resides in the JDK bin directory. To generate the java classes from the WSDL, follow the steps mentioned below.- Article by Kunal Chowdhury on
The Web Services Description Language (WSDL) is an XML based interface definition language that is used for describing the functionality offered by a SOAP web service. If you have a WSDL file and you want to generate java classes (.java and .class) from it, there are number of ways.
In this quick 'how-to' article, we will learn how to generate java classes using the 'wsimport' command that by default comes with JDK.
If you would like to parse a WSDL file to generate java classes, you can use the wsimport
tool. This 'wsimport' tool comes with the JDK (Java Development Kit) and resides in the JDK bin
directory. To generate the java classes from the WSDL, follow the steps mentioned below:
- Open the
Run dialog, type cmd and hitEnter to open the Console Window. - Enter the following command to navigate to the JDK 'bin' directory:
cd '%JAVA_HOME%\bin'
- Now enter the following command by properly filling the [TARGET_NAMESPACE], [SOURCE_DIRECTORY], [OUTPUT_DIRECTORY] and [WSDL_URL] in the below console command to start generating the java files:
wsimport -keep -p [TARGET_NAMESPACE] -s [SOURCE_DIRECTORY] -d [OUTPUT_DIRECTORY] [WSDL_URL]
Points to note that:
- The
- The
- The
- The
We do have another approach to parse and generate java classes from WSDL. That uses JAX-WS Maven Plugin. Check it out and learn how to use it.