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!

3 Comments

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.

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

Leave a comment

About confuseAcat

user-pic Random observations that may in some way be related to Perl.