Perhaps I'm missing something in what you're trying to do, but you might
try Apache::SOAP. Apache::SOAP makes it super-easy to call perl
subroutines running under mod_perl.
I have something like this in my apache config, which maps requests to a
Perl module:
<Location "/soaptest">
SetHandler perl-script
PerlHandler Apache::SOAP
PerlSetVar dispatch_to "Some::Module"
</Location>
and then, my module:
package Some::Module;
sub add {
my ($val1, $val2) = @_;
my $result = $val1 + $val2;
return $result;
}
sub subtract {
my ($val1, $val2) = @_;
my $result = $val1 - $val2;
return $result;
}
1;
Nothing necessarily SOAP specific there.
With that code, I can call these subroutines with client code that looks
like:
use SOAP::Lite;
use strict;
my $soap = SOAP::Lite
-> proxy('http://my.server.com/soaptest')
-> uri('Some/Module');
my $result1 = $soap->add( 2 , 4 );
print "2 + 4 = $result1 \n";
my $result2 = $soap->subtract( 4 , 2 );
print "4 - 2 = $result2 \n";
This way you don't need to deal with all of the SOAP::Transport details,
etc.
--Colin
On Mon, 2004-09-27 at 11:30, Ken Miller wrote:
> A few years back, I had played around with SOAP and mod_perl -
> everything worked fine, but for various reasons I ended up not using
> SOAP. I'm back looking at it, and I'm running into a problem I don't
> remember having before.
>
> Here's the script I'm running:
>
> my $sl = SOAP::Lite-> proxy( 'http://localhost:7070/soaptest',
> cookie_jar => $cookie_jar )
> -> uri( '/soaptest' )
> -> on_debug([EMAIL PROTECTED]);
>
> $sl->Runner( SOAP::Data->name( blotto => 'foobarius' ) );
>
> print $sl->result, "\n";
>
> Here's the request posted to the server (server names changed to protect
> the innocent):
>
> POST http://localhost:7070/soaptest
> Accept: text/xml
> Accept: multipart/*
> Content-Length: 499
> Content-Type: text/xml; charset=utf-8
> SOAPAction: "/soaptest#runner"
>
> <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:runner
> xmlns:namesp1="/soaptest"><blotto
> xsi:type="xsd:string">foobarius</blotto></namesp1:runner></SOAP-ENV:Body></SOAP-ENV:Envelope>
>
> The /soaptest URI causes this code to be executed on the server:
>
> package Test::SoapServer;
>
> use strict;
> use SOAP::Transport::HTTP::Apache;
>
> sub handler {
> my $safe_classes = {
> Runner => undef,
> };
> my $rc = SOAP::Transport::HTTP::Apache->handler($safe_classes);
> return $rc;
> }
>
> package Runner;
> use strict;
>
> sub new {
> bless {}, shift;
> }
>
> sub handle_request {
>
> print STDERR "-------SOAP HANDLER START -----------\n";
>
> my ($self, $headers, $body, $envelopeMaker) = @_;
>
> $body->{extra_stuff} = "body extra_stuff";
>
> foreach my $header (@$headers) {
> $header->{extra_stuff} = "header extra_stuff";
> $envelopeMaker->add_header(undef, undef, 0, 0, $header);
> }
> my $rc = $envelopeMaker->set_body(undef, 'myresponse', 0, $body);
> print STDERR "-------SOAP HANDLER END -----------\n";
>
> return $rc;
> }
>
> 1;
>
> and here's the response I get:
>
> HTTP/1.1 400 Bad Request
> Connection: close
> Date: Mon, 27 Sep 2004 14:59:05 GMT
> Server: Apache/1.3.31
> Content-Type: text/html; charset=iso-8859-1
> Client-Date: Mon, 27 Sep 2004 14:59:05 GMT
> Client-Peer: 155.10.37.51:7070
> Client-Response-Num: 1
> Client-Transfer-Encoding: chunked
> Title: 400 Bad Request
> X-Cache: MISS from localhost
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>400 Bad Request</TITLE>
> </HEAD><BODY>
> <H1>Bad Request</H1>
> Your browser sent a request that this server could not understand.<P>
> [libapreq] unknown content-type: `text/xml; charset=utf-8'<P>
> </BODY></HTML>
>
> From inspecting SOAP::Lite::Transport::HTTP::Apache, the error is being
> generated here:
>
> my %args = $r->args();
> unless (exists $args{class}) {
> return BAD_REQUEST;
> }
>
> The %args hash is empty, most likely because libapreq doesn't understand
> the POST'ed XML data - see the error message above regarding the
> 'unknown content type.'
>
> Note that this all works fine if I use the daemon method of writing a
> SOAP server, but for obvious reasons I want to use mod_perl.
>
> So, what's the solution to this? The client wants to send XML data, yet
> the server is especting to receive posted form data. I've looked
> through the docs, but I've yet to find a solution. From searching the
> mailing lists, I did find one question that matched this on almost
> exactly, but there were no responses.
>
> Software Versions:
>
> Perl: 5.6.1
> libapreq: 1.3
> Apache: 1.3.31
> mod_perl: 1.29
> MIME::Lite: 2.117
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html