I’ve been looking for a good framework in Perl to write Web Services and it looks like there isn’t. I believe the two main reasons for that is because Perl’s Weak Typing nature and lack of out of the box subroutine signature, this means that the compiler doesn’t know at compile time what parameters and which type does a subroutine needs. While in one hand this give you a flexible language in the other hand it makes almost impossible any attempt of meta-descriptions.
The traditional approach to write a Web Service in Perl is to write the backend to attend client’s petitions and the meta-descriptive documents ( XSD and WSDL). Now imagine you have a Web Service and you want to turn it into a JSON-RPC service, this means that part of your backend has to be re-written - at least the parser - also you have to write new meta-descriptive documents in this case SMD. To go a little bit further imagine if you want to have both, this is more likely to create a maintenance hell, any change in one piece may trigger changes in all other pieces and if you want to continue offering different faces ( WS, JSON-RPC, Rest, … ) this becomes a task for a team of highly trained monkeys.
Strong Typed languages like Java have fancy frameworks that help you build WS in seconds through the use of Annotations also something that Perl lacks of. Those frameworks take care of creating the baking meta-descriptive documents, this is very productive as you don’t have to create/maintain them, any changes you make to the backend is immediately reflected in service description documents.
Fortunately Perl subroutines have attributes which is a sort of annotations flexible enough if you keep a minimal syntax. Attributes can be used to describe for example the subroutine’s parameters and their data types and/or the return value, that information should be sufficient to fill the gap and bring easy to create/maintain services into Perl.
That’s something I’m trying to hack in a project called “Domuyo” which intends to be a framework for creating web services easily in Perl, to give you a feeling how a controller class would look like here’s a snippet:
And the framework would be responsible of creating the XSD, WSDL, SMD or any other meta-descriptive document as well as parse the request and dispatch it. At this moment I’ve parts of the skeleton of the framework and made a couple of proof of concepts scripts and as soon as I’ve something to release I will definitely do. Don’t switch the channel.