views:

74

answers:

1

I'm currently dealing with a code base which contains several dozens of classes generated with SOAP::WSDL. However, having worked with Moose I now think that generating those classes at runtime at meta level (i.e. not to files on disk but directly to objects) might be a better idea (completely excluding performance reasons at this point).

  1. Is this approach sensible? The idea is to avoid changes to generated code and also to avoid re-generating it once in a while.

  2. If so, are there any ready-to-use Perl modules that create classes from a WSDL?

+1  A: 

To answer the second question first, there is nothing Moose based that will turn a WSDL into a set of classes. However you could possibly build something based on XML::Toolkit. For full disclosure XML::Toolkit is my module that has tools for converting SAX streams into Moose classes and vice versa. For non-Moose Perl classes, there is XML::Compile which I believe can compile SOAP wsdl -> Perl.

To answer the first question, my experience with XML::Toolkit says that keeping the classes in memory at run-time is tricky. Ignoring the performance overhead there is a lot of stuff you'll need to keep in your head that are inflated from the WSDL. It would be an interesting experiment, but I"m not sure how long-term maintainable it would be.

I've wanted for a long time to try something like this but I haven't had a project that paid me to really focus on it. Unfortunately I don't have the free time to tackle a project of this size either.

perigrin