18.13. Writing a SOAP Server
18.13.1. Problem
You
want to write a web service where SOAP is the transport.
18.13.2. Solution
Use the SOAP-Lite distribution from CPAN. Your server can be either
standalone:
use SOAP::Transport::HTTP;
$daemon = SOAP::Transport::HTTP::Daemon
->new(LocalPort => $PORT)
->dispatch_to(''ClassName'')
->handle( );
or a CGI script:
use SOAP::Transport::HTTP;
$daemon = SOAP::Transport::HTTP::CGI
->dispatch_to(''ClassName'')
->handle( );
In both cases, the only methods that SOAP clients are permitted to
invoke are those in the classes named in the argument to
dispatch_to (those classes will be
require d if not already loaded):
package ClassName;
sub handler {
my ($class, $arg_hash_ref) = @_;
# ...
}
18.13.3. Discussion
The SOAP-Lite toolkit contains SOAP and XML-RPC modules. Writing a
SOAP service is similar to writing an XML-RPC service. Control method
dispatch in SOAP as in XML-RPC. See Recipe 18.11 for details.
18.13.4. See Also
Recipe 18.14; Recipe 18.11