SOAP::Transport::TCP - SOAP Server with TCP Protocol

This section provides a tutorial example on how to use the SOAP::Transport::TCP module to create a SOAP server with the TCP protocol.

Let's look at one of the SOAP server API module first. SOAP::Transport::TCP has sub module called SOAP::Transport::TCP::Server. It offers two functionalities: 1. Taking SOAP requests as a SOAP server; 2. Interacting with application modules to handle the requests as a SOAP server side API.

Main functions of SOAP::Transport::TCP::Server are:

new(LocalAddr=>'hostname', LocalPort=>'port', Listen=>'queueSize') - Constructs and returns SOAP server object that listens on the specified host name at the specified port with the specified queue size.

dispatch_to('Module::method') - Defines the module name and the method name that can be called by the incoming SOAP request for this server, and returns this server object.

handle() - Puts this server in waiting mode for incoming SOAP request. Whenever a SOAP request comes, it will be automatically passed to the module name and the method name defined by the dispatch_to() function based on the SOAP action name in the request.

Here is a sample program to show you how to create a SOAP server with TCP as the transportation protocol:

#- SoapTcpServer.pl
#- Copyright (c) 2002 by Dr. Herong Yang, http://www.herongyang.com/
   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();

This program will create a SOAP server on localhost at 8001, and dispatch SOAP request to Hello::hello, if the SOAP action name matches it. Here is my Hello module code:

#- Hello.pm
#- Copyright (c) 2002 by Dr. Herong Yang, http://www.herongyang.com/
   package Hello;
   sub hello {
     shift;
     return "Hello " . shift;
   }
1;

If you run SoapTcpServer.pl, you will get this:

SOAP TCP server listening...
   Host: 127.0.0.1
   Port: 8001

The SOAP server is ready. Now you need a SOAP client program to talk the SOAP server. See the next section to know how to write a SOAP client program.

Table of Contents

 About This Book

 Perl on Linux Systems

 ActivePerl on Windows Systems

 Data Types: Values and Variables

 Expressions, Operations and Simple Statements

 User Defined Subroutines

 Perl Built-in Debugger

 Name Spaces and Perl Module Files

 Symbolic (or Soft) References

 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 Files in Binary Mode

 Open Directories and Read File Names

 File System Functions and Operations

 Converting Perl Script to Executable Binary

 Using DBM Database Files

 Using MySQL Database Server

 Socket Communication Over the Internet

 XML::Simple Module - XML Parser and Generator

 XML Communication Model

SOAP::Lite - SOAP Server-Client Communication Module

 What Is SOAP?

 What Is SOAP::Lite?

SOAP::Transport::TCP - SOAP Server with TCP Protocol

 SoapTcpClient.pl - SOAP Client Example with TCP Protocol

 SOAP::Lite Tracing Functions

 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

 LWP::UserAgent and Web Site Testing

 References

 PDF Printing Version