What Is WSDL2Java?

This section describes WSDL2Java - A command line tool that generates Java classes from an existing WSDL document to represent client stubs, server skeletons and data types. WSDL2Java is distributed as part of the Axis2 package.

What is WSDL2Java? WSDL2Java is a command line tool that generates Java classes from an existing WSDL document. Generated classes represent client stubs, server skeletons and data types that will helps you to write client side and server Java programs for Web services defined in the WSDL document.

WSDL2Java is distributed as part of the Axis2 package developed by Apache. Since I installed Axis2 1.4.1 in \local\axis2 folder on my Windows system, I can run WSDL2Java with no argument to get help information about WSDL2java:

C:\herong>set JAVA_HOME=\local\jdk

C:\herong>set AXIS2_HOME=\local\axis2

C:\herong>\local\axis2\bin\wsdl2java
Using AXIS2_HOME:   \local\axis2
Using JAVA_HOME:    \local\jdk
Usage: WSDL2Java [options] -uri <url> : A url or path to a WSDL

where [options] include:
-o <path>      Specify a directory path for the generated code.
-a             Generate async style code only (Default: off).
-s             Generate sync style code only (Default: off). 
               Takes precedence over -a.
-p <pkg1>      Specify a custom package name for the generated code.
-l <language>  Valid languages are java and c (Default: java).
-t             Generate a test case for the generated code.
-ss            Generate server side code (i.e. skeletons) 
               (Default: off).
-sd            Generate service descriptor (i.e. services.xml).
               (Default: off). Valid with -ss.
-d <databinding>   Valid databinding(s) are adb, xmlbeans, jibx and
               jaxbri (Default: adb).
-g             Generates all the classes. Valid only with -ss.
-pn <port_name>   Choose a specific port when there are multiple
               portsin the wsdl.
-sn <service_name>   Choose a specific service when there are multiple
               services in the wsdl.
-u             Unpacks the databinding classes
-r <path>      Specify a repository against which code is generated.
-ns2p ns1=pkg1,ns2=pkg2  Specify a custom package name for each 
               namespace specified in the wsdls schema.
-ssi           Generate an interface for the service implementation 
               (Default: off).
-wv <version>  WSDL Version. Valid Options : 2, 2.0, 1.1
-S             Specify a directory path for generated source
-R             Specify a directory path for generated resources
-em            Specify an external mapping file
-f             Flattens the generated files
-uw            Switch on un-wrapping.
-xsdconfig <file path>   Use XMLBeans .xsdconfig file. Valid only with
               -d xmlbeans.
-ap            Generate code for all ports
-or            Overwrite the existing classes
-b             Generate Axis 1.x backward compatible code.
-sp            Suppress namespace prefixes (Optimzation that reduces size of soap request/response)
-E<key> <value>   Extra configuration options specific to certain
               databindings.
--noBuildXML   Dont generate the build.xml in the output directory
--noWSDL       Dont generate WSDLs in the resources directory
--noMessageReceiver   Dont generate a MessageReceiver in the generated
               sources
--http-proxy-host   Proxy host address if you are behind a firewall
--http-proxy-port   Proxy port address if you are behind a firewall
-ep            Exclude packages - these packages are deleted after
               codegeneration
-sin           Skeleton interface name - used to specify a name for 
               skeleton interface other than the default one
-scn           Skeleton class name - used to specify a name for skeleton
               class other than the default one

Last update: 2009.

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

 WSDL 2.0 Document Examples with SOAP Binding

 WSDL 20 Programming APIs and Testing Tools

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 soapUI 3.0.1 - Web Service Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension in PHP 5.3.1

 Using WSDL in Perl with SOAP::Lite 0.710

 Using WSDL Document in Java with Axis2 1.4.1

Using WSDL2Java to Generate Web Service Stub Classes

What Is WSDL2Java?

 Generating Client Side Stub Java Code

 Stub and Data Type Classes

 Using Stub and Data Type Classes

 XML Document Based Web Service Example

 "Unexpected subelement ..." Error from the Stub Class

 RPC Method Based Web Service Example

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

 WSDL Related Terminologies

 References

 PDF Printing Version