WSDL2Java Converting WSDL 2.0 Documents to Stub Classes

This section provides a tutorial example how to use WSDL2Java to generate a client stub class from a WSDL 2.0 document.

After failed loading WSDL 2.0 document with the ServiceClient class, I tried to use Axis2 1.4.1 WSDL2Java command line tool to generate a client stub class from my WSDL 2.0 document with the "-wv 2.0" option:

C:\herong>\local\axis2\bin\wsdl2java -o wsdl2 -d adb -s -wv 2.0 
   -uri Hello_WSDL_20_SOAP.wsdl
Using AXIS2_HOME:   \local\axis2
Using JAVA_HOME:    \local\jdk

C:\herong>dir Wsdl2\src\com\herongyang\www\service

Good. The stub class generation was successful. Here is Java program to test the stub class, .\wsdl2\src\

 * Copyright (c) 2009 by Dr. Herong Yang,
 * All rights reserved
import com.herongyang.www.service.*;
import com.herongyang.www.service.HelloServiceStub.*;
import org.apache.axis2.transport.http.*;
class Axis2StubHelloWsdl20 {
   public static void main(String[] args) {
      PrintStream out = System.out;
      try {

// Creating the stub
         HelloServiceStub stub = new HelloServiceStub();

// Fixing org.apache.axis2.AxisFault: Transport error: 
//    411 Error: Length Required

// Building the input parameter
         Hello request = new Hello();
         request.setHello("Hello from Stub client.");

// Calling the operation
         HelloResponse response = stub.Hello(request);

// Retrieving output parameter
         String output = response.getHelloResponse();

      } catch (Exception e) {

The execution result was good too:

C:\herong>cd wsdl2\src



   -Djava.ext.dirs=\local\axis2\lib\ Axis2StubHelloWsdl20

      Hello from server -

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

 List of APIs and Tools

 ServiceClient Class Loading WSDL 2.0 Documents

WSDL2Java Converting WSDL 2.0 Documents to Stub Classes

 What Is Woden 1.0?

 WSDL 2.0 Component Model

 WSDL 2.0 Component Model - Test

 WSDL 2.0 Element Model

 WSDL 2.0 Element Model Test

 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

 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


 PDF Printing Version