#!/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 = 9000;
my $SERVER_NAME = 'localhost';
# Create a SOAP server object
my $soap_server = SOAP::Transport::HTTP::Daemon
-> new (LocalAddr => $SERVER_NAME, LocalPort => $SERVER_PORT )
# 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('/data/jeff/soap');
# 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();
####
use strict;
use LWP;
use LWP::UserAgent;
#use diagnostics;
# Turn off in production code capitalize expects to
# receive one argument. It returns that argument,
# capitalized, using Perl's built-in
# capitalization (uc) function.
sub capitalize
{
my $self = shift;
my $word = shift;
return uc ($word);
}
####
#!/usr/bin/perl -w
use strict;
use diagnostics; # Remove from production code
use SOAP::Lite;
# Pass the command-line argument for capitalization
my $result = SOAP::Lite -> uri('Text/Caps') ->
proxy('http://localhost:9000')
-> capitalize('Mares Eat Oats, And Does Eat Oats, and Little Lambs Eat Ivy')
-> result() || '';
# Print the result
print "Result = '$result'\n";
####
Result = 'MARES EAT OATS, AND DOES EAT OATS, AND LITTLE LAMBS EAT IVY'
####
Result = ''