Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 4.00

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.

Sections in This Chapter

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

Dr. Herong Yang, updated in 2009
Testing SOAP::Lite Client Objects