Outdated: Calling GetSpeech SOAP 1.2 with SAAJ

This section provides a tutorial example on how to call the GetSpeech SOAP 1.2 Web service provided at xmlme.com with the SOAPConnection class defined in SAAJ.

I think I am ready to call the GetSpeech SOAP 1.2 Web service at www.xmlme.com now:

/* SOAPConnectionGetSpeech12.java
 * Copyright (c) HerongYang.com. All Rights Reserved.
 * All rights reserved
import java.io.*;
import javax.xml.soap.*;
import javax.xml.soap.Name;
import javax.xml.namespace.QName;
public class SOAPConnectionGetSpeech12 {
   public static void main(String[] args) {
      PrintStream out = System.out;

// Checking command line arguments
      if (args.length < 1) {
         out.println("java SOAPConnectionGetSpeech12 phrase");
      String phrase = args[0];
      String sURL = "http://www.xmlme.com/WSShakespeare.asmx";

      try {
// Creating a new empty SOAP message object
         SOAPMessage reqMsg = MessageFactory.newInstance(

// Populating SOAP body
         String prefix = "tns";
         String uri = "http://xmlme.com/WebServices";
         SOAPEnvelope envelope = reqMsg.getSOAPPart().getEnvelope();
         SOAPBody body = envelope.getBody();
         SOAPBodyElement service = body.addBodyElement(
            envelope.createName("GetSpeech", prefix, uri));
         SOAPElement param = service.addChildElement(
            envelope.createName("Request", prefix, uri));

// Connecting and calling
   SOAPConnection con 
      = SOAPConnectionFactory.newInstance().createConnection();
         SOAPMessage resMsg = con.call(reqMsg, sURL);

// Parsing the response
         body = resMsg.getSOAPBody();

      } catch (Exception e) {

My test result:

C:\herong>java SOAPConnectionGetSpeech12 "To be, or not to be"
be: that is the question: Whether 'tis nobler in the mind to suffer

Congratulations again!

Table of Contents

 About This Book

 Introduction to Web Service

 Introduction to SOAP (Simple Object Access Protocol)

 SOAP Message Structure

 SOAP Message Transmission and Processing

 SOAP Data Model

 SOAP Encoding

 SOAP RPC Presentation

 SOAP Properties Model

 SOAP MEP (Message Exchange Patterns)

 SOAP HTTP Binding

 SOAP PHP Implementations

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

 PHP SOAP Web Service Example - getTemp

 SOAP Perl Implementations

 Perl SOAP::Lite - SOAP Server-Client Communication Module

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

 Perl SOAP::Lite for SOAP 1.2 Web Services

 Perl SOAP::Lite for WSDL

 SOAP Java Implementations

 Java Socket and HttpURLConnection for SOAP

 SAAJ - SOAP with Attachments API for Java

 SoapUI - SOAP Web Service Testing Tool

 WS-Security - SOAP Message Security Extension

 WS-Security X.509 Certificate Token

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

 Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Perl SOAP::Lite 0.710 for WSDL

 Web Services and SOAP Terminology

Outdated Tutorials

 Outdated SOAP::Lite 0.55 in ActivePerl 5.8.7

 Outdated: SOAP 1.1 Request - Content-Length Too Small

 Outdated: SOAP 1.1 Request - Content-Length Too Large

 Outdated: SOAP 1.1 Request and Response of GetSpeech

 Outdated: SOAP 1.2 Request and Response of GetSpeech

 Outdated: Calling GetSpeech SOAP 1.1 with SAAJ

Outdated: Calling GetSpeech SOAP 1.2 with SAAJ


 Full Version in PDF/EPUB