lmocsi has asked for the wisdom of the Perl Monks concerning the following question:
I'm using Perl to write a web-service, but some weird thing is happening to me: if I use ->on_action() to modify the SoapAction (I need to use soapaction: "http://my.website.com/Apple/foo/getanswer"), the soap message disappears and a hash reference is returned, pointing to a small part of the soap message. What am I doing wrong?
... and the package Apple.pm beside:#!c:/perl/bin/perl.exe -w use Apple; use SOAP::Transport::HTTP; my $soap = SOAP::Transport::HTTP::CGI ->dispatch_with({ 'http://my.website.com/Apple/foo/getanswer' => 'A +pple' }) ->on_action(sub { join '/foo/', @_; }) ->dispatch_to('Apple') ->handle;
I'm testing it with the following code:#!c:/perl/bin/perl.exe package Apple; use strict; sub getanswer{ my ($self,$soap,$other) = @_; return('Original soap message: '.$soap); } 1;
use strict; use SOAP::Lite +trace => 'debug'; $SOAP::Constants::PREFIX_ENV = "soapenv"; # Original: SOAP-ENV $SOAP::Constants::PREFIX_ENC = "soapenc"; # Original: SOAP-ENC my $ns_apple = "http://my.website.com/Apple"; my $host = "https://localhost/cgi-bin/apple_in.cgi"; # my $ns = "urn:apple"; my $cert = 'my_cert.cer'; $ENV{HTTPS_CERT_FILE} = $cert; my $soap_req = ' <apple:tree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml +ns:xsd="http://www.w3.org/2001/XMLSchema"> <mycontent code="112233"> <otherstuff value="123456" accuracy="20.0" timestamp="2013-04-06 + 23:26:16" /> </mycontent> </apple:tree> '; my $soap = SOAP::Lite ->readable(1) ->on_action( sub { join '/foo/', @_ } ) # ->uri($ns) ->proxy($host) ->autotype(0); my $som = $soap->call(SOAP::Data->name('apple:getanswer') ->attr({"xmlns:apple" => $ns_apple }) =>SOAP::Data->type('xml' => $soap_req +) ); die $som->faultstring if ($som->fault); my $res = $som->result; print "The response from the server was:\n".$res."\n";
All I get back is: "HASH(0x1e84ebc)", referring to the string: "mycontent". What am I doing wrong?
UpdateA workaround could be if I change the test code (and the message sent) like this:
$soap_req =~ s/</</g; ... my $som = $soap->call(SOAP::Data->name('apple:getanswer') ->attr({"xmlns:apple" => $ns_apple }) =>SOAP::Data->name('soap') ->type('xsd:string'=> $so +ap_req) );
But I would not like to change the soap message, I just want to turn off automatic deserialization of the soap message at server side, to get access to the original soap body. How can I do that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Soap message turns to hash reference
by igelkott (Priest) on Apr 06, 2013 at 23:27 UTC | |
by lmocsi (Novice) on Apr 06, 2013 at 23:38 UTC | |
by Anonymous Monk on Apr 07, 2013 at 00:44 UTC | |
by lmocsi (Novice) on Apr 07, 2013 at 12:23 UTC | |
by Anonymous Monk on Apr 07, 2013 at 13:22 UTC | |
| |
|
Re: Soap message turns to hash reference
by Anonymous Monk on Apr 07, 2013 at 15:14 UTC | |
by lmocsi (Novice) on Apr 07, 2013 at 19:44 UTC | |
by Anonymous Monk on Apr 08, 2013 at 01:36 UTC | |
by Anonymous Monk on Apr 08, 2013 at 02:04 UTC | |
by Anonymous Monk on Apr 08, 2013 at 02:06 UTC |