[Xml-compile] Help with compiling serializers and de-serializers

Bill Moseley moseley at hank.org
Wed May 25 13:01:57 GMT 2011


On Tue, May 24, 2011 at 11:40 PM, Mark Overmeer <mark at overmeer.net> wrote:

> * Bill Moseley (moseley at hank.org) [110525 00:57]:
> > I took your suggestion and used the approach used in
> XML::Compile::Daemon.
> > Thanks very much for the help.  It was easier to start fresh than work
> > backwards from the Catalyst::Controller::SOAP code.
>
> Great. Is it code to share?
>

Still needs work and docs.  And I'm sure there's code that could be done
more efficiently (suggestions welcome).

Here's the controller Role:

http://hank.org/CatalystX/TraitFor/Controller/SOAP.pm

and here's the "ActionClass" that runs the XML::Compile::SOAP handler for
each request.

 http://hank.org/CatalystX/Action/SOAP.pm


> I essentially build handler callback subs that call out to methods in a
> > Catalyst controller (e.g. sub createPerson {} ).  In my callback sub I
> wrap
> > the call out to the Catalyst controller method in an eval and on an
> > exception I return { Fault =3D> { ... } } hash.  This results in a nice
> SOAP
> > fault response -- well a nice generic server error message.
>
> You can change all components of the fault produced, so not only the
> generic default
>

I just meant I catch unexpected errors that happen in the callback function
and return a generic fault -- "oops, unexpected server error"  kind of
message.

As for my question:

When an XML request comes into Catalyst the request must be prepared before
calling the XML::Compile callback.  For example, I check that it's a POST
and use XML::LibXML to parse the document.  If anything fails during that
time I want to provide a SOAP fault.

What I'm currently doing is calling that "soap_fault" method in the Trait
linked above.  That soap_fault method returns a simple fault response in the
http response.   But, I assume there's another way to generate that fault
XML using XML::Compile.

For example, say I require a SOAPAction header, then I have this code:

   return $self->soap_fault( "Missing SOAPAction header" ) unless
$request->header( 'soapaction' );

What would you write for that soap_fault method to have it build a SOAP XML
fault response?



Thanks,

-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20110525/b1=
e2ae5b/attachment.htm


More information about the Xml-compile mailing list