Creating Service Client with WSDL 1.1 Document

This section provides a tutorial example on how to create a ServiceClient object with a given WSDL document, a service name and a port name defined in the WSDL document.

Before looking at other Axis2 class, let's take a closer look at how to create a service client object from an existing WSDL document using this constructor method:

   org.apache.axis2.client.ServiceClient client =
      new ServiceClient(null, wsdlURL, serviceQName, portName)
// "null" indicates a default ConfigurationContext object to be used
// "wsdlURL" specifies a WSDL document using a new URL(wsdlUrlString)
// "serviceQName" specifies a service within the WSDL document
//    using a new QName(tns,serviceName)
//    "tns" specifies the target namespace of the Web service
// "portName" specifies a port within the service using the port name

Now let's write a test program,, to create a service client with my hello WSDL document, which is located at

 * Copyright (c) 2009 All Rights Reserved.
import javax.xml.namespace.QName;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
class Axis2ServiceClientHello {
   public static void main(String[] args) {
      PrintStream out = System.out;

// Setting initial values
      ConfigurationContext config = null;
      String server = "";
      String wsdl = server+"Hello_WSDL_11_SOAP.wsdl";
      String tns = "";
      String serviceName = "helloService";
      String portName = "helloPort";

      try {

// Creating a dynamic service client with a given WSDL
         ServiceClient client = new ServiceClient(
            new URL(wsdl),
            new QName(tns, serviceName),

// Printing ServiceClient object information
         out.println("ServiceClient object information:");
         out.println("   client: "+client);
         out.println("   client.getAxisConfiguration(): "
         out.println("   client.getAxisService(): "
         out.println("   client.getOptions(): "
         out.println("   client.getServiceContext(): "
         out.println("   client.getTargetEPR(): "

      } catch (Exception e) {

I can compile this program with the "-Djava.ext.dirs=\local\axis2\lib\" option with JDK 1.8 or earlier versions, so it will automatically all JAR files in that directory in the class path.

But with JDK 9 or higher, I got this error:

herong> javac -Djava.ext.dirs=\local\axis2\lib\ \

javac: option -extdirs not allowed with target 1.10

One workaround is the use "-cp .;\local\axis2\lib\*" option:

herong> javac -cp .;\local\axis2\lib\*

herong> java -cp .;\local\axis2\lib\* Axis2ServiceClientHello

log4j:WARN No appenders could be found for logger ...
log4j:WARN Please initialize the log4j system properly.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
   to method
WARNING: Please consider reporting this to the maintainers of
WARNING: Use --illegal-access=warn to enable warnings of further
   illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

ServiceClient object information:
   client: org.apache.axis2.client.ServiceClient@1
   client.getAxisService(): helloService
   client.getOptions(): org.apache.axis2.client.Options@6995bf68
   client.getTargetEPR(): null

Notes on the test program code and output:

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

 Using WSDL Document in Java Apache Axis2/Java for WSDL

 Apache Woden for WSDL Documents in Java

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

Apache Axis2/Java for WSDL 1.1

Creating Service Client with WSDL 1.1 Document

 org.apache.axis2.client.Options - Operation Client Options

 sendReceive() Method - Invoking a Named Operation

 Turning Off the Chunked HTTP Flag

 AXIOM (AXIs Object Model) - document/literal Style

 org.apache.axis2.rpc.client.RPCServiceClient Class - rpc/encoded Style - Socket Server Testing Program

 Capturing the HTTP Request from an Axis2 Client Program

 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

 Python SOAP Client: Zeep

 WSDL Related Terminologies

 Archived Tutorials


 Full Version in PDF/EPUB