Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Custom serializer and Apache2::SOAP

by john_oshea (Priest)
on Nov 27, 2007 at 18:32 UTC ( #653330=perlquestion: print w/ replies, xml ) Need Help??
john_oshea has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a Apache2::SOAP system working all fine and dandy, and now I want to add in a custom serializer and I'm having a total brainfart as to where to actually add it. The standalone server example (following) does what I want, but I can't actually see where I'd add in the equivalent of the ->serializer() line in a Apache2::SOAP setup:

my $daemon = SOAP::Transport::HTTP::Daemon ->new( LocalAddr => 'localhost', LocalPort => 8080, Re +use => 1 ) ->serializer(My::Serializer->new) ->dispatch_to('My::Server'); BEGIN { package My::Serializer; @My::Serializer::ISA = 'SOAP::Serializer'; sub envelope { $_[2] = (SOAP::Data->name($_[2]) ->prefix('foo') ->uri('http://www.example.org') ) if $_[1] =~ /^(?:method|response)$/; shift->SUPER::envelope(@_); } }

The dispatch_to line in the appropriate httpd.conf section? Somewhere else? Any pointers would be very gratefully accepted.

Thanks

Comment on Custom serializer and Apache2::SOAP
Select or Download Code
Re: Custom serializer and Apache2::SOAP
by rob_au (Abbot) on Nov 28, 2007 at 00:00 UTC

    The way that I have done this in the past is to create my own class that inherits from Apache::SOAP and incorporates a new constructor that includes the call to the serializer function.

    For example:

    package My::SOAP; use Apache::SOAP; use strict; use vars qw( @ISA $VERSION ); # This class inherits from the Apache::SOAP class and is intended to + provide # functionality relating to the SOAP server itself, rather than the +exposed # web services. @ISA = qw( SOAP::Transport::HTTP::Apache ); my $server = __PACKAGE__->new; sub new { my $self = shift; unless( ref $self ) { $self = __PACKAGE__->SUPER::new( @_ ); $self->serializer( My::SOAP::Serialiser->new ); # The following on_action handler is intended to make this w +eb service .NET # friendly by modifying the SOAPAction header to fit the for +m of URI#method # (the form preferred by SOAP::Lite) where the SOAPAction he +ader is of the # form URI/method (that employed by the .NET framework). $self->on_action( sub { ( my $action = shift ) =~ s/^("?)(.*)\1$/$2/; if( $action && $action ne join( '#', @_ ) && $action ne join( '/', @_ ) && ( substr( $_[0], -1, 1 ) ne '/' || $action ne join( '', @_ ))) { $self->action( join '#', @_ ); } } ); } return $self; } 1; __END__

    (This code, although slightly modified to protect the innocent, is from an Apache::SOAP server implementation that was developed for interface from .NET solution components and shows one way to implement your own serialiser within Apache::SOAP derived solutions).

     

    perl -le "print unpack'N', pack'B32', '00000000000000000000001000000000'"

      Thank you. That makes so much more sense than the arrant nonsense I was attempting yesterday... ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://653330]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-05 17:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls