- document/literal Style

This section provides a tutorial example on how to build a SOAP Body message in document/literal style and call the Registration Web service.

With the help of AXIOM classes and methods, I can write my first real Axis2 client program now,

In this program, I used the WSDL document located at Registration_WSDL_11_SOAP_11_Document.wsdl. This Web services uses the document/literal message style.

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

// Setting initial values
      String server = "";
      String wsdl = server+"Registration_WSDL_11_SOAP_11_Document.wsdl";
      String tns = "";
      String serviceName = "registrationService";
      String portName = "registrationPort";

      try {
         ServiceClient client = new ServiceClient(null,
            new URL(wsdl), new QName(tns, serviceName), portName);
         Options option = client.getOptions();

// Building SOAP Body element for the request
         OMFactory factory = OMAbstractFactory.getOMFactory();
         OMNamespace namespace = factory.createOMNamespace(tns, "hy");
         OMElement request = factory.createOMElement(
            "RegistrationRequest", namespace);
         request.addAttribute("event", "OpenGame", namespace);
         request.addAttribute("date", "2018-08-08", namespace);

         OMElement guest1 = factory.createOMElement(
            "Guest", namespace);
         guest1.setText("Herong Yang");

         OMElement guest2 = factory.createOMElement(
            "Guest", namespace);
         guest2.setText("Joe Smith");

// Printing the request as an XML string
   out.println("Request XML message");
         OMElement response = client.sendReceive(
      new QName(tns, "Registration"), request);

// Printing the response as an XML string
   out.println("Response XML message");
      } catch (Exception e) {

Output of this program is presented below:

Request XML message
   hy:event="OpenGame" hy:date="2018-08-08">
   <hy:Guest>Herong Yang</hy:Guest>
   <hy:Guest>Joe Smith</hy:Guest>

Response XML message
   <hy:Confirmation guest="Herong Yang" event="OpenGame" />
   <hy:Confirmation guest="Joe Smith" event="OpenGame" />

This is very cool! My first Axis2 client program worked nicely.

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