habit_forming has asked for the wisdom of the Perl Monks concerning the following question:

Hey you Monks!

I am using SOAP::Transport::HTTP::Apache in the suggested way... a.k.a SOAP::Transport::HTTP::Apache->dispatch_to($modules_path,@modules)->handler(@_); And that works great! But I want to add a way for the modules to call warn and that warning be encoded in the returning XML.

Is there a way to intercept the returning XML and add arbitary (properly formatted) values to it?

--habit

Replies are listed 'Best First'.
Re: Add custom return parms to SOAP::Transport::HTTP::Apache
by Fletch (Bishop) on May 11, 2004 at 16:38 UTC

    Subclass SOAP::Transport::HTTP::Apache and override dispatch_to. In your version, set up a local warn handler (local $SIG{__WARN__} = sub { ... }) which stores off any error text then call $self->SUPER::dispatch_to( ...  ). After that returns, muck with the XML to add whatever your warn handler stored (if anything).

      Well I tried that but unfortunately the XML to be returned is not actaully returned by the $self->SUPER::dispatch_to( ...  ) function but is print'ed somewhere deep in the SOAP::* modules. (I have not found out exactly where yet.)

      So my options are kind-of limited. =(

      --habit

        Hrmm, looks like it's returned by SOAP::Transport::HTTP::Server by calling a coderef (look for $response_content_writer in SOAP::Transport::HTTP::Apache) which is passed to its handle_request method (which prints to an Apache instance obtained with Apache->request()). All of the class names are hardcoded so there's not really a clean way to subclass. What you're going to have to do is basically make your own version of S::T::H::Apache and modify the coderef to do the error mucking.