Perl Tutorials - Herong's Tutorial Examples - Version 5.32, by Dr. Herong Yang
SOAP::Lite Tracing Functions
This section provides a tutorial example on how to use the SOAP::Lite tracing function to dump tracing information of the communication session for debugging.
In the sample programs shown in the previous section, you don't see any SOAP XML messages. And you don't see how the server and the client send messages to each other. All of these are hidden behind SOAP::Lite modules. If you want to know more about how SOAP::Lite modules work, you can turn on the trace function on the SOAP::Lite module.
Here is the revised server program with trace on:
#- SoapTcpServerTrace.pl #- Copyright (c) 2002 by Dr. Herong Yang, http://www.herongyang.com/ use SOAP::Lite +trace; use SOAP::Transport::TCP; my $daemon = SOAP::Transport::TCP::Server ->new(LocalAddr => 'localhost', LocalPort => 8001, Listen => 5); $daemon->dispatch_to('Hello::hello'); print "SOAP TCP server listening...\n"; print " Host: ", $daemon->sockhost, "\n"; print " Port: ", $daemon->sockport, "\n"; $daemon->handle();
Here is the revised client program with trace on:
#- SoapTcpClientTrace.pl #- Copyright (c) 2002 by Dr. Herong Yang, http://www.herongyang.com/ use SOAP::Lite +trace; my $client = SOAP::Lite->new(); $client->uri('urn:Hello'); $client->proxy('tcp://localhost:8001'); my $som = $client->hello("Herong"); my $output = $som->result; print $output . "\n";
Running the server first, and then the client, you will get on the client side:
SOAP::Transport::new: () SOAP::Serializer::new: () SOAP::Deserializer::new: () SOAP::Parser::new: () SOAP::Lite::new: () SOAP::Transport::TCP::Client::new: () SOAP::Lite::call: () SOAP::Serializer::envelope: () SOAP::Serializer::envelope: hello Herong SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Transport::TCP::Client::send_receive: <?xml version="1.0" encodi ng="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap. org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org /soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envel ope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd= "http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:hello xmlns :namesp1="urn:Hello"><c-gensym3 xsi:type="xsd:string">Herong</c-gensym 3></namesp1:hello></SOAP-ENV:Body></SOAP-ENV:Envelope> SOAP::Transport::TCP::Client::send_receive: <?xml version="1.0" encodi ng="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap. org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org /soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envel ope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd= "http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:helloRespon se xmlns:namesp1="urn:Hello"><s-gensym3 xsi:type="xsd:string">Hello He rong</s-gensym3></namesp1:helloResponse></SOAP-ENV:Body></SOAP-ENV:Env elope> SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () SOAP::SOM::new: () Hello Herong SOAP::Lite::DESTROY: () SOAP::Serializer::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Transport::TCP::Client::DESTROY: () SOAP::SOM::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Parser::DESTROY: ()
On the server side, you will get:
SOAP::Serializer::new: () SOAP::Deserializer::new: () SOAP::Parser::new: () SOAP::Server::new: () SOAP::Transport::TCP::Server::new: () SOAP TCP server listening... Host: 127.0.0.1 Port: 8001 SOAP::Server::handle: () SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () SOAP::SOM::new: () SOAP::Data::new: () SOAP::Data::DESTROY: () (eval): Herong SOAP::Server::handle: Hello Herong SOAP::Serializer::envelope: () SOAP::Serializer::envelope: helloResponse Hello Herong SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::SOM::DESTROY: ()
Now you see the SOAP XML request, and the response generated by SOAP::Lite modules.
Table of Contents
Data Types: Values and Variables
Expressions, Operations and Simple Statements
Name Spaces and Perl Module Files
Hard References - Addresses of Memory Objects
Objects (or References) and Classes (or Packages)
Typeglob and Importing Identifiers from Other Packages
String Built-in Functions and Performance
File Handles and Data Input/Output
Open Directories and Read File Names
File System Functions and Operations
Converting Perl Script to Executable Binary
Socket Communication Over the Internet
XML::Simple Module - XML Parser and Generator
►SOAP::Lite - SOAP Server-Client Communication Module
SOAP::Transport::TCP - SOAP Server with TCP Protocol
SoapTcpClient.pl - SOAP Client Example with TCP Protocol
SOAP::Transport::HTTP - SOAP Server with HTTP Protocol
Perl Programs as IIS Server CGI Scripts
CGI (Common Gateway Interface)
XML-RPC - Remote Procedure Call with XML and HTTP
RPC::XML - Perl Implementation of XML-RPC
Integrating Perl with Apache Web Server
CGI.pm Module for Building Web Pages