Perl Tutorials - Herong's Tutorial Examples - Version 5.32, by Dr. Herong Yang
SoapTcpClient.pl - SOAP Client Example with TCP Protocol
This section provides a tutorial example on how to use the SOAP::Lite module to create a SOAP client program, SoapTcpClient.pl, with the TCP protocol.
SOAP:Lite represents the SOAP client API that allows you to send a Perl function call as a SOAP request to the specified SOAP server, and receive the result of the call as a SOAP response from the server. Main functions of SOAP::Lite are:
new() - Constructs a new SOAP::Lite object, and returns it.
uri('uri') - Defines the URI (Universal Resource Identifier) of the target module to be called, and returns the same object.
proxy('url') - Defines the URL (Universal Resource Locator) of the SOAP server, and returns the same object.
'method'() - Allows to call the method from the target module on the SOAP server, and returns a new SOAP::SOM object representing the outcome of the call.
$som->result - A property of a SOAP::SOM object representing the returning scalar value of the call.
Here is a sample program to show you how to use SOAP::LITE module to request a function call to the SOAP server I created in the previous section.
#- SoapTcpClient.pl #- Copyright (c) 2002 by Dr. Herong Yang, http://www.herongyang.com/ use SOAP::Lite; # 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";
Run it while the SoapTcpServer.pl is running, you will get:
Hello Herong
This is amazing. You can create a simple SOAP server and client in less than 20 lines of source code!
Note that the proxy URL must have "tcp" as the protocol name, since the SOAP server is running with TCP as the transportation protocol.
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