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

This section describes 3 other Axis2 classes: org.apache.axis2.description.AxisService, org.apache.axis2.client.Options and org.apache.axis2.addressing.EndpointReference.

Once we have a ServiceClient object created, we can learn 3 other related classes.

1. org.apache.axis2.description.AxisService - A class represents a Web service itself.

2. org.apache.axis2.client.Options - A class represents a holder for operation client options. It is used by the other classes in this package to configure various aspects of how a client communicates with a service.

3. org.apache.axis2.addressing.EndpointReference - A class models the WS-A EndpointReferenceType. But it can be used without any WS-A handlers as well since the models for this in Submission and Final versions are different.

Here is a test program that shows some properties of these classes:

/**
 * Axis2ServiceClientGetMethod.java
 * Copyright (c) 2009 by Dr. Herong Yang, herongyang.com
 * All rights reserved
 */
import java.io.PrintStream;
import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.client.Options;
import org.apache.axis2.addressing.EndpointReference;
class Axis2ServiceClientGetMethod {
   public static void main(String[] args) {
      PrintStream out = System.out;

// Setting initial values
      String wsdl = "file:///C:/herong/Hello_WSDL_11_SOAP.wsdl";
      String tns = "http://www.herongyang.com/Service/";
      String serviceName = "helloService";
      String portName = "helloPort";

      try {

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

// Printing AxisService object information
         AxisService service = client.getAxisService();
         out.println();
         out.println("AxisService object information:");
         out.println("   service: "+service);
         out.println("   service.getCustomSchemaNamePrefix(): "
            +service.getCustomSchemaNamePrefix());
         out.println("   service.getFileName(): "
            +service.getFileName());
         out.println("   service.getName(): "
            +service.getName());
         out.println("   service.getServiceDescription(): "
            +service.getServiceDescription());
         out.println("   service.getSoapNsUri(): "
            +service.getSoapNsUri());
         out.println("   service.getTargetNamespace(): "
            +service.getTargetNamespace());
         out.println("   service.getTargetNamespacePrefix(): "
            +service.getTargetNamespacePrefix());

// Printing Options object information
         Options options = client.getOptions();
         out.println();
         out.println("Options object information:");
         out.println("   options: "+options);
         out.println("   options.getAction(): "
            +options.getAction());
         out.println("   options.getSoapVersionURI(): "
            +options.getSoapVersionURI());
         out.println("   options.getTransportInProtocol(): "
            +options.getTransportInProtocol());

// Printing EndpointReference object information
         EndpointReference endpoint = options.getTo();
         out.println();
         out.println("EndpointReference object information:");
         out.println("   endpoint: "+endpoint);
         out.println("   endpoint.getAddress(): "
            +endpoint.getAddress());
         out.println("   endpoint.getName(): "
            +endpoint.getName());

      } catch (Exception e) {
         e.printStackTrace(); 
      }
   }
}

Execution of this program is described below:

C:\herong>\local\jdk\bin\java -Djava.ext.dirs=\local\axis2\lib\
   Axis2ServiceClientGetMethod
log4j:WARN No appenders could be found for logger 
   (org.apache.axis2.description. WSDL11ToAxisServiceBuilder).
log4j:WARN Please initialize the log4j system properly.

AxisService object information:
   service: helloService
   service.getCustomSchemaNamePrefix(): null
   service.getFileName(): null
   service.getName(): helloService
   service.getServiceDescription():
    Hello_WSDL_11_SOAP.wsdl
    Copyright (c) 2007 by Dr. Herong Yang, herongyang.com
    All rights reserved

   service.getSoapNsUri(): null
   service.getTargetNamespace(): http://www.herongyang.com/Service/
   service.getTargetNamespacePrefix(): tns

Options object information:
   options: org.apache.axis2.client.Options@148bd3
   options.getAction(): null
   options.getSoapVersionURI():
      http://schemas.xmlsoap.org/soap/envelope/
   options.getTransportInProtocol(): null

EndpointReference object information:
   endpoint:
      Address: http://www.herongyang.com/Service/Hello_SOAP_11.php
   endpoint.getAddress():
      http://www.herongyang.com/Service/Hello_SOAP_11.php
   endpoint.getName(): null

Notes on the test program code and output:

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

 What Is Axis2?

 Downloading and Installing Axis2/Java 1.4.1

 org.apache.axis2.client.ServiceClient Class

 Creating Service Client with WSDL 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)

 Axis2RegistrationClient.java - document/literal Style

 Axis2GetSpeechClient.java - document/literal Style

 org.apache.axis2.rpc.client.RPCServiceClient Class

 Axis2GetExchangeRateClient.java - rpc/encoded Style

 SocketRequestResponseServer.java - 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

 WSDL Related Terminologies

 References

 PDF Printing Version