GetSpeech_SOAP_1_1.pl - SOAP::Lite for SOAP 1.1 Web Service

This section provides a tutorial example on how to use the SOAP::Data class to build the request parameter element with correct element name and a namespace. My first SOAP::Lite program works now with the GetSpeech Web service.

After going through various testing programs, I finalized my GetSpeech program for SOAP 1.1 as, GetSpeech_SOAP_1_1.pl:

#- GetSpeech_SOAP_1_1.pl
#- Copyright (c) 2009 HerongYang.com. All Rights Reserved.
#- All rights reserved
#
   use SOAP::Lite;

   my $proxy = 'http://www.xmlme.com/WSShakespeare.asmx';
   my $uri = 'http://xmlme.com/WebServices';
   my $method = "GetSpeech";
   my $soapAction = sub {return "$uri/$method"};
   
   my ($phrase) = @ARGV;

#- Building the parameter element
   my $parameter = SOAP::Data
        ->name("Request") # set the element name
        ->value($phrase) # set the value
        ->uri($uri); # set namespace

#- Creating the SOAP client object
   my $client = SOAP::Lite->new()
      ->proxy($proxy) # set the proxy URL
      ->on_action($soapAction) # set the SOAPAction
      ->uri($uri); # set the namespace

#- Calling the Web service
   my $som = $client->call($method=>($parameter));
   my $output = $som->result;
   print $output . "\n";

Here is what I did in the final version:

When executing GetSpeech_SOAP_1_1.pl, I got this:

herong> GetSpeech_SOAP_1_1.pl "To be, or not to be"
<SPEECH><PLAY>HAMLET</PLAY><SPEAKER>HAMLET</SPEAKER>
To be, or not to be: that is the question: Whether 'tis nobler 
in the mind to suffer The slings and arrows of outrageous fortune, 
...</SPEECH>

Now you can try it with different phrases from Shakespeare's plays.

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

 Python SOAP Client: Zeep

 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

 GetSpeech Failed - Incorrect SOAPAction Header Line

 GetSpeech Failed - Incorrect Parameter Name c-gensym

 Using Socket Program to Request Parameter Name

 GetSpeech Worked - Using SOAP::Data Class and on_action() Function

GetSpeech_SOAP_1_1.pl - SOAP::Lite for 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

 Archived Tutorials

 References

 Full Version in PDF/EPUB