LibraryLink ToToggle FramesPrintFeedback

Generating the Stub Code

The wsdl2java tool generates the stub code from the WSDL contract. The stub code provides the supporting code that is required to invoke operations on the remote service.

For consumers, the wsdl2java tool generates the following types of code:

To generate consumer code use the wsdl2java tool. Enter the following command at a command-line prompt:

wsdl2java -ant -client -d outputDir hello_world.wsdl

Where outputDir is the location of a directory where the generated files are placed and hello_world.wsdl is a file containing the contract shown in Example 3.1. The -ant option generates an ant build.xml file, for use with the ant build utility. The -client option generates starting point code for the consumer's main() method.

For a complete list of the arguments available for the wsdl2java tool see wsdl2java in Tool Reference.

If you are using Apache Ant as your build system, you can call the code generator using Ant's java task, as shown in Example 5.1.


The command line options are passed to the code generator using the task's arg element. Arguments that require two strings, such as -d, must be split into two arg elements.

The preceding command generates the following Java packages:

  • org.apache.hello_world_soap_http — This package is generated from the http://apache.org/hello_world_soap_http target namespace. All of the WSDL entities defined in this namespace (for example, the Greeter port type and the SOAPService service) map to Java classes this Java package.

  • org.apache.hello_world_soap_http.types — This package is generated from the http://apache.org/hello_world_soap_http/types target namespace. All of the XML types defined in this namespace (that is, everything defined in the wsdl:types element of the HelloWorld contract) map to Java classes in this Java package.

The stub files generated by the wsdl2java tool fall into the following categories: