/usr/share/doc/libpoe-component-server-soap-perl/examples/test-server.perl is in libpoe-component-server-soap-perl 1.14-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #!/usr/bin/perl
use strict; use warnings;
# Include the local directory to LIB
use FindBin qw($Bin);
use lib "$Bin/../lib";
use POE;
sub POE::Component::Server::SOAP::DEBUG () { 2 }
use POE::Component::Server::SOAP;
POE::Component::Server::SOAP->new(
'ALIAS' => 'MySOAP',
'ADDRESS' => 'localhost',
'PORT' => 32080,
'HOSTNAME' => 'MyHost.com',
);
POE::Session->create(
inline_states => {
_start => \&setup_service,
_stop => \&shutdown_service,
Sum_Things => \&do_sum,
Dump_Things => \&do_dump,
LocalTime => \&do_time,
Get_XML => \&do_xml,
}
);
$poe_kernel->run;
exit 0;
sub setup_service {
my $kernel = $_[KERNEL];
$kernel->alias_set( 'MyServer' );
$kernel->post( 'MySOAP', 'ADDMETHOD', 'MyServer', 'Sum_Things' );
$kernel->post( 'MySOAP', 'ADDMETHOD', 'MyServer', 'Get_XML' );
$kernel->post( 'MySOAP', 'ADDMETHOD', 'MyServer', 'Dump_Things', 'MyServer', 'DUMP' );
$kernel->post( 'MySOAP', 'ADDMETHOD', 'MyServer', 'LocalTime', 'TimeServer', 'Time' );
}
sub shutdown_service {
$_[KERNEL]->post( 'MySOAP', 'DELMETHOD', 'MyServer', 'Sum_Things' );
$_[KERNEL]->post( 'MySOAP', 'DELMETHOD', 'MyServer', 'DUMP' );
$_[KERNEL]->post( 'MySOAP', 'DELSERVICE', 'TimeServer' );
}
sub do_sum {
my $response = $_[ARG0];
my $params = $response->soapbody;
my $sum = 0;
while (my ($field, $value) = each(%$params)) {
$sum += $value;
}
# Fake an error
if ( $sum < 100 ) {
$_[KERNEL]->post( 'MySOAP', 'FAULT', $response, 'Add:Error', 'The sum must be above 100' );
} else {
$response->content( $sum );
$_[KERNEL]->post( 'MySOAP', 'DONE', $response );
}
}
sub do_dump {
my $response = $_[ARG0];
require Data::Dumper;
$response->content( Data::Dumper::Dumper( $response->soapbody ) );
$_[KERNEL]->post( 'MySOAP', 'DONE', $response );
}
sub do_time {
my $response = $_[ARG0];
$response->content( scalar( localtime() ) );
$_[KERNEL]->post( 'MySOAP', 'DONE', $response );
#$_[KERNEL]->post( 'MySOAP', 'SHUTDOWN', 'GRACEFUL' );
}
sub do_xml {
my $response = $_[ARG0];
$response->content( '<data><var1>57</var1><var2>abc</var2></data>' );
$_[KERNEL]->post( 'MySOAP', 'RAWDONE', $response );
}
|