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!
OK, those hobbs on IRC were "awesome".
And the only description of the module itself is "isn't really helpful".
I dare say it's unfair.
Oh, sorry. To be fair, the module works very well and I'm grateful you put it on CPAN. But saying that the documentation isn't really helpful actually was quite fair.
I didn't post this here to shame you, but to promote the module and tell the world how to use it. Because that's exactly what the module deserves.
The best way to handle this is to provide a doc patch for the module to help anyone else who tries to use it. Then the module's documentation becomes awesome too. :D