Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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>

Replies are listed 'Best First'.
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?
[Corion]: This is vaguely inspired by that list of "nasty" strings, which I'd like to replace among HTTP parameters, just to see whether the application crashes, but also for easy downloading of a list of URLs etc
[Corion]: Maybe I'll just conoct something using Algorithm::Permute to create an (OO) generator for such requests, or a simple function.
[Corion]: For testing I imagine one would want to test a random sampling of such "bad"/"unexpected" requests, while for downloading, one would want to generate them all in order, but not necessarily as a huge list
[Corion]: s/Algorithm:: Permute/Algorithm ::Loops/

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2017-01-16 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (151 votes). Check out past polls.