Click here to get back home

POE and SOAP

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
POE and SOAP Mpapec 03-14-2008
Posted by Mpapec on March 14, 2008, 8:56 am
Please log in for more thread options

I want to build small soap server which should provide persistent DBI
statement handles. POE::Component::Server::SOAP handles one client at
the time, so there is a lot of waiting for other clients.

I've tried to change perldoc example so the server wouldn't block, but
now server doesn't respond at all. :)
http://search.cpan.org/~apocal/POE-Component-Server-SOAP-1.11/lib/POE/Component/Server/SOAP.pm



server
++++++
use strict;
use warnings;

use Data::Dumper;
use POE;
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,

task_result => \&handle_task_result,
task_done => \&handle_task_done,
task_debug => \&handle_task_debug,
},
);

$poe_kernel->run;
exit 0;

sub setup_service {
my $kernel = $_[KERNEL];
$kernel->alias_set( 'MyServer' );
$kernel->post( 'MySOAP', 'ADDMETHOD', 'MyServer', 'Sum_Things' );
}
sub shutdown_service {
$_[KERNEL]->post( 'MySOAP', 'DELMETHOD', 'MyServer',
'Sum_Things' );
}


sub do_sum {

my $response = $_[ARG0];
my $params = $response->soapbody;

use POE qw(Wheel::Run Filter::Reference);
my $task = POE::Wheel::Run->new(
Program => sub { do_stuff($response, $params) },
StdoutFilter => POE::Filter::Reference->new(),
StdoutEvent => "task_result",
StderrEvent => "task_debug",
CloseEvent => "task_done",
);
}



sub do_stuff {
binmode(STDOUT); # Required for this to work on MSWin32
my ($response, $params) = @_;

my $filter = POE::Filter::Reference->new();
# console output
my $output = $filter->put( [ $response ] );
print @$output;

# soap client output
$response->content(
[
{ res => $_[HEAP]++ },
]
);
$_[KERNEL]->post( 'MySOAP', 'DONE', $response );

}

sub handle_task_result {
my $result = $_[ARG0];
print Dumper $result;
}

# Catch and display information from the child's STDERR. This was
# useful for debugging since the child's warnings and errors were not
# being displayed otherwise.
sub handle_task_debug {
my $result = $_[ARG0];
print "Debug: $result\n";
}

# The task is done. Delete the child wheel, and try to start a new
# task to take its place.
sub handle_task_done {
# my ( $kernel, $heap, $task_id ) = @_[ KERNEL, HEAP, ARG0 ];
# delete $heap->->;
# $kernel->yield("next_task");
}




client
++++++
use Data::Dumper;
use SOAP::Lite;
my $client = SOAP::Lite
-> uri('http://localhost:32080/')
-> proxy('http://localhost:32080/?session=MyServer');
my $response = $client->Sum_Things( {
'FOO' => 'bax',
'Hello' => 'World!',
}
);

print Dumper $response->result;

Similar ThreadsPosted
Re: SOAP April 9, 2008, 12:57 pm
WSDL/SOAP/XML-RPC HELP August 20, 2004, 5:39 pm
soap::Lite help please May 21, 2006, 10:00 am
SOAP Error June 3, 2006, 2:27 am
SOAP::LITE November 10, 2006, 6:44 am
SOAP::Lite August 21, 2007, 6:23 pm
Another SOAP::Lite August 21, 2007, 9:23 pm
Starting with SOAP August 22, 2007, 1:24 pm
SOAP timing out September 27, 2007, 4:39 pm
how to serialze in soap::lite August 19, 2004, 7:47 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap