Testing SOAP::Lite Client Objects

This section provides a tutorial example on testing methods that are available on SOAP::Lite 0.710 client object.

To verify methods listed in the previous tutorial, I wrote this test program, SOAP_Lite_Client_Object.pl:

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

#- Creating a client object with default properties
   my $client = SOAP::Lite->new();

#- Sets the proxy object with protocol, server and end point
   $client->proxy('http://localhost/');

#- Resets the end point
   $client->endpoint('http://localhost/Demo_Service');

#- Sets the service object. It loads the WSDL immediately
#- So don't use it unless the WSDL is available
#  $client->service('http://localhost/Demo_Service_WSDL');

#- Turns on the flag to receive raw XML in the response
   $client->outputxml(true);

#- Turns on the flag to auto automatically deduce types 
#- for the data used in the request message
   $client->autotype(true);
   
#- Turns on the flag to make the request message readable
#- using spaces and line breaks
   $client->readable(true);

#- Sets the current namespace with a prefix
   $client->ns('http://herongyang.com/', 'hy');

#- Sets SOAP version to 1.2
   $client->soapversion('1.2');

#- Sets prefix of the SOAP envelop namespace
   $client->envprefix('env');

#- Sets prefix of the SOAP encoding namespace
   $client->encprefix('enc');
   
#- Calls the server and send the request
#- $client->call('GetProfile',"Herong Yang");

#- Prints information with get methods
   print "\n\$client: ".$client;
   print "\n\$client->transport(): ".$client->transport();
   print "\n\$client->serializer(): ".$client->serializer();
   print "\n\$client->packager(): ".$client->packager();
   print "\n\$client->proxy(): ".$client->proxy();
   print "\n\$client->endpoint(): ".$client->endpoint();
   print "\n\$client->service(): ".$client->service();
   print "\n\$client->outputxml(): ".$client->outputxml();
   print "\n\$client->autotype(): ".$client->autotype();
   print "\n\$client->readable(): ".$client->readable();
   print "\n\$client->default_ns(): ".$client->default_ns();
   print "\n\$client->ns(): ".$client->ns();
   print "\n\$client->soapversion(): ".$client->soapversion();
   print "\n\$client->envprefix(): ".$client->envprefix();
   print "\n\$client->encprefix(): ".$client->encprefix();
   print "\n\$client->encoding(): ".$client->encoding();
   print "\n\$client->typelookup(): ".$client->typelookup();
   print "\n\$client->multirefinplace(): ".$client->multirefinplace();
   print "\n\$client->parts(): ".$client->parts();
   print "\n\$client->on_action(): ".$client->on_action();
   print "\n\$client->on_nonserialized(): "
      .$client->on_nonserialized();

Here is the output of the test program:

$client: SOAP::Lite=HASH(0x1a8e008)
$client->transport(): SOAP::Transport=HASH(0x36038)
$client->serializer(): SOAP::Serializer=HASH(0x1a8dcfc)
$client->packager(): SOAP::Packager::MIME=HASH(0x1a8df30)
$client->proxy(): SOAP::Transport::HTTP::Client=HASH(0x1a8e26c)
$client->endpoint(): http://localhost/Demo_Service
$client->service():
$client->outputxml(): true
$client->autotype(): true
$client->readable(): true
$client->default_ns(): http://herongyang.com/
$client->ns(): http://herongyang.com/
$client->soapversion(): 1.2
$client->envprefix(): env
$client->encprefix(): enc
$client->encoding(): UTF-8
$client->typelookup(): HASH(0x1924a24)
$client->multirefinplace(): 0
$client->parts(): SOAP::Lite=HASH(0x1a8e008)
$client->on_action(): CODE(0x1a5c240)
$client->on_nonserialized(): CODE(0x18f7534)

I think I have a good idea on how to use the SOAP::Lite client class now.

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

 Message Styles Supported in SOAP::Lite

 Methods on SOAP::Lite Client Object

Testing SOAP::Lite Client Objects

 Differences between SOAP 1.1 and SOAP 1.2

 NumberToWords_localhost.pl - Testing on Local Host

 soapversion('1.2') and envprefix('soap12') Must Used Together

 default_ns() - Setting Namespace for Body Elements

 SOAP::Data - Utility Class to Generate XML Elements

 SOAPAction - Not Needed, But No Way to Remove It

 NumberToWords_SOAP_1_2.pl - SOAP::Lite for SOAP 1.2 Web Service

 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

 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