Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Adding namespace in Method Response

by Anonymous Monk
on Aug 12, 2010 at 21:08 UTC ( #854766=note: print w/ replies, xml ) Need Help??


in reply to Adding namespace in Method Response

See Re^3: How to get SOAP Tags in SOAP::Lite Server (and Re^3: How to get SOAP Tags in SOAP::Lite Server) and Quick Start with SOAP and POE/Component/Server/SOAP.pm

my $content = SOAP::Serializer->prefix( 's' )->envelope( 'response', SOAP::Data->name( $response->soapmethod() . 'Response' )->uri( + $response->soapuri() ), # Do we need to serialize the content or not? ( $_[STATE] eq 'RAWDONE' ? SOAP::Data->type( 'xml', $response- +>content() ) : $response->content() ), );
I believe, uri() corresponds to namesp1, so combining all that information I have
#!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; my $content = SOAP::Serializer->prefix('s')->envelope( 'response', SOAP::Data->name( 'hi' . 'Response' ) ->uri( 'namesp1' ), 'Hello', ); print $content,"\n"; __END__
which outputs a body
$ perl soap-lite-uri-namespace.pl |xml_grep --nowrap soap:Body |xml_pp <soap:Body> <namesp1:hiResponse xmlns:namesp1="namesp1"> <s-gensym3 xsi:type="xsd:string">Hello</s-gensym3> </namesp1:hiResponse> </soap:Body>


Comment on Re: Adding namespace in Method Response
Select or Download Code
Re^2: Adding namespace in Method Response
by inzoik (Novice) on Aug 12, 2010 at 23:14 UTC
    Thank you , thank you, thank you - I cant thank you enough number of times for the example.

    I had probably looked at that piece of code 4-5 times yet it didn't strike me as the relevant.

    So I reviewed what POE is doing in the sub TransactionDone section in http://cpansearch.perl.org/src/APOCAL/POE-Component-Server-SOAP-1.14/lib/POE/Component/Server/SOAP.pm. I also looked at http://cookbook.soaplite.com/#changing%20method%20name%20in%20response including the discussion section and came up with the following cgi which worked perfectly.

    use SOAP::Transport::HTTP; my $server = new SOAP::Transport::HTTP::CGI ->serializer(MySerializer->new) ->dispatch_to('Demo') ->handle(); BEGIN { package MySerializer; @MySerializer::ISA = qw/SOAP::Serializer/; sub envelope { $_[2] = SOAP::Data->name($_[2])->uri($_[0]->uri()) if +$_[1] =~ /^(?:method|response)$/; shift->SUPER::envelope(@_); } } package Demo; use SOAP::Lite; sub hi { return 'Hello'; }

    After that got working perfectly I had to do the following to get it all working under mod_perl

    1. Added a Location section as follows

    <Location /session> Order Deny,Allow SetHandler perl-script PerlHandler SOAP::Apache </Location>
    2. Added the following in my startup handler
    package MySerializer; @MySerializer::ISA = qw/SOAP::Serializer/; sub envelope { $_[2] = SOAP::Data->name($_[2])->uri($_[0]->uri()) if $_[1] =~ + /^(?:method|response)$/; shift->SUPER::envelope(@_); } package SOAP::Apache; use SOAP::Transport::HTTP; my $server = SOAP::Transport::HTTP::Apache ->serializer(MySerializer->new) -> dispatch_to(... ... ...); sub handler { $server->handler(@_) } 1;
    Currently the XML looks great under SOAP::Trace - will have more feedback tomorrow after the .Net client gives it a shot.

    Again thanks a lot for guiding me.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-12-25 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls