RFC: SOAP module with implicit WSDL generation

RFC: SOAP module with implicit WSDL generation

am 04.04.2008 20:38:12 von Christian Winter

Hi there,

for my current job, I've put together a module that
makes it easier to build basic web services around
SOAP::Transport::HTTP::CGI and that provides an
implicit functionality to generate the appropriate
WSDL file. It's still a bit of a hack, as it's simply
aimed to DWIM.

Basically, it consists of a module "WSDL::Easy" that's
used as the base class for all webservices, and a
submodule WSDL::Easy::Attribute that also employs
attribute magic and some TIE stuff. As a result, you
simply inherit from WSDL::Easy and declare your methods
like:

sub webmethod1
:in( "lala" => "string", "lolo" => "int" )
:out( "result" => "string" )
{
my( $class, $self ) = @_;
return [{ "result" => $self->{"lala"} . $self->{"lolo"} }];
}

In the CGI service script you include your module,
instantiate it with the name and SOAP-URI for the service
and invoke it's dispatch() method. If called with a GET
parameter of "WSDL", it returns the WSDL definition file,
though currently only for RPC style formatting.

At the time being, the return value is always an array
with the first element containing all the parameters defined
in the :out attribute, as this was the quickest way to get
Perl and PHP5 (which currently makes up the client side) to agree
on how to handle it.

More complex types will follow, for the first part I'll
implement nesting via hash/array refs in the in/out attributes.
Later on, I also plan to make it possible to define own complex
types separately from the subroutine using it.

I'd like to know if you've got any thoughts on that, either
wishes you have for such a module, practical experience
from work or caveats to consider, as I'm planning on releasing
it to CPAN once it's reasonably stable and tested, and I'd
rather avoid adding just another hardly-used WSDL thingy to
the repository.

-Chris