Listing 2: A Simple Standalone SOAP Server. This program waits to receive SOAP requests on port 8080, and hands them to an appropriate object.
#!/usr/bin/perl -w
use strict;
use diagnostics;
# Remove from production code
use SOAP::Transport::HTTP;
# Get the object for standalone servers
my $SERVER_PORT = 8080;
my $SERVER_NAME = 'localhost';
# Create a SOAP server object
my $soap_server = SOAP::Transport::HTTP::Daemon
-> new (LocalAddr => $SERVER_NAME, LocalPort =>
# What is the root directory for our objects?
# (Remember, the default Perl @INC path will
# be ignored.)
# Do *not* use /tmp on a real server!
-> dispatch_to('/tmp/');
# Indicate on which port we're expecting
# SOAP requests
print "SOAP server is waiting on port $SERVER_PORT...\n";
# Now handle the incoming SOAP method call,
# and return an appropriate SOAP response.
$soap_server->handle();
Copyright © 1994 - 2018 Linux Journal. All rights reserved.