# Server system
# This is a test of one Web Service Server
use strict;
use SOAP::Transport::HTTP;
use Demo;
my $port = 8080;
my $host = 'localhost';
SOAP::Transport::HTTP::Daemon
->new(LocalAddr => $host, LocalPort => $port, Reuse => 1)
->dispatch_with({ 'urn:Demo' => 'Demo' })
->objects_by_reference('Demo')
->handle;
exit;
####
# The package demo !
package Demo;
use subs qw( Sub1 Sub2 );
sub Sub1
{
my %Test= ( 'Test01' => 1,
'Test02' => 1,
'Test99' => 1 );
return %Test;
}
sub Sub2
{
my @Test = qw (2 3 4 5 6 7 8 9 10);
return @Test;
}
1;
####
# Client side
use SOAP::Lite;
my $endpoint = shift || 'http://localhost:8080';
my $soap = SOAP::Lite->uri('urn:Demo')
->proxy($endpoint);
my %Test = $soap->Sub1()->result;
foreach my $Key01 ( keys %Test )
{
print "Key : $Key01\n";
}