How to use SOAP::Transport::HTTP::Plack
I needed to port a little cgi-script that implements a simple SOAP-server to Plack. After a little searching, I came across SOAP::Transport::HTTP::Plack.
Unfortunately, the documentation of this module is ... not really helpful.
Here's my (slightly modified) cgi-script:
#!/usr/bin/perl
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
->dispatch_to(
'/some/directory',
'Some::SOAP::Module1',
'Some::SOAP::Module2',
)->handle;
Simple enough.
After some help of the awesome hobbs on IRC, here's part of my Plack psgi file:
use Plack::Builder;
use Plack::Request;
use SOAP::Transport::HTTP::Plack;
my $soap = SOAP::Transport::HTTP::Plack->new;
my $soap_app = sub {
my $env = shift;
return $soap
->dispatch_to(
'/some/directory',
'Some::SOAP::Module1',
'Some::SOAP::Module2',
)->handler( Plack::Request->new( $env ) );
};
return builder {
mount
'/soap_test' => $soap_app;
}
And low and behold, it works!