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_0_710_Client_Object.pl:

#- SOAP_Lite_0_710_Client_Object.pl
#- Copyright (c) 2009 by Dr. Herong Yang, 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 tink I have a good idea on how to use the SOAP::Lite 0.710 client class now.

Last update: 2009.

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 Message Exchange Patterns

 SOAP HTTP Binding

 SOAP Perl Implementations

 SOAP PHP Implementations

 SOAP Java Implementations

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

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Installing SOAP::Lite 0.710 to Support SOAP 1.2

 Features in SOAP::Lite 0.710

 Methods on SOAP::Lite 0.710 Client Object

Testing SOAP::Lite Client Objects

 Request Differences between SOAP 1.1 and SOAP 1.2

 GetSpeech_localhost.pl - Testing GetSpeech on Local Host

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

 default_ns() - Setting Default namespace for Body Elements

 SOAP::Data - Utility Class to Generate XML Elements

 SOAPAction - Not Needed, But No Way to Remove It

 Unsupported Media Type: "application/soap"

 DEFAULT_HTTP_CONTENT_TYPE='application/soap+xml'

 content_type() method in the HTTP::Headers Class

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

 Perl SOAP::Lite 0.710 for WSDL

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

 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

 Web Services and SOAP Terminology

 References

 PDF Printing Version