First off, apologies for the HTML mail. It's all I have access to at the moment.
Here is the behavior exhibited on my machine.
1. The example server in the POD synopsis seems to respond to requests, but the
accompanying client example doesn't print anything.
2. If I make a request to the example server with SOAPsh.pl, included with SOAP::Lite,
the most I can expect back is a 400 Bad Request.
I'll keep playing around with the module in case I have missed something obvious.
As promised the other day, here is what I have working. My script certainly *IS* a
proof-of-concept and is not as elegant as a native component. :P
---
use strict;
use POE qw( Component::Server::HTTP );
use SOAP::Transport::HTTP::Server;
my $httpd = POE::Component::Server::HTTP->new (
Port => 80,
ContentHandler => {
'/soap/' => \&soap_handler
},
Headers => {
Server => 'SomeServer 0.1'
}
);
$poe_kernel->run;
exit;
sub soap_handler {
my ($request, $response) = @_;
my $request_header_reader = sub {
my ($base_name, $standard_cgi_header) = @_;
my $s = lc ($base_name);
$s =~ s/-/_/g;
my $header = $request->headers->header ($s);
$header =~ s/;.+$// if $s eq 'content_type';
$header;
};
my $s = SOAP::Transport::HTTP::Server->new();
my $content;
my $request_content_reader = sub { $_[0] = $request->content };
my $response_header_writer = sub { $response->headers->header (@_) };
my $response_content_writer = sub { $content.= shift };
my $optional_dispatcher = sub {
my ($class, $headers, $body, $em) = @_;
die "Invalid request\n" unless defined $body;
my $method_name = $body->{soap_typename};
my @param_ids;
foreach my $key (grep /^c-gensym\d+$/, keys %$body) {
my ($idx) = $key =~ /(\d+)$/;
push @param_ids, $idx;
}
my @params = @{$body}{map { "c-gensym$_" } sort { $a <=> $b } @param_ids};
my $return_value;
if (lc $method_name eq 'sum_things') {
$return_value += $_ foreach @params;
} else {
die "Invalid method specified\n";
}
$em->set_body (
$body->{'soap_typeuri'},
$method_name.'Response',
0, {
return => $return_value
}
);
};
$s->handle_request (
$request->method,
undef,
$request_header_reader,
$request_content_reader,
$response_header_writer,
$response_content_writer,
$optional_dispatcher
);
$response->code (RC_OK);
$response->content ($content);
return RC_OK;
}
-----Original Message-----
From: Rocco Caputo [mailto:[EMAIL PROTECTED]
Sent: Thu 11/6/2003 11:23 AM
To: [EMAIL PROTECTED]
Cc:
Subject: Re: soap server
On Mon, Nov 03, 2003 at 09:30:03AM -0800, Peter Guzis wrote:
> There is a POE::Component::Server::SOAP component for POE already, but
> I wasn't able to get it working. I suspect Rocco made it as a proof
> of concept, but he will know better than I do.
>
> It is possible to just use POE::Component::Server::HTTP and send off
> the request data to, IIRC, SOAP::Transport::HTTP::Server. I did this
> successfully last week, but don't have the code in front of me right
> now. I'll have more info later.
I harbor illusions that it's a functional, useful module, albeit rather
limited in scope (namely, it's tied to the HTTP transport).
If you could provide a test case to illustrate the problems you're
having with it, I'll be happy to address what issues I can.
Also, if you can generalize your server into a proper component, I would
be happy to let you take over the POE::Component::Server::SOAP
namespace. I haven't done any SOAP work, so I'm not as experienced as I
should be as author of this component.
--
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/