Hello,

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?


I have an "apple_in.cgi" in the Apache cgi-bin directory
#!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;
... and the package Apple.pm beside:
#!c:/perl/bin/perl.exe package Apple; use strict; sub getanswer{ my ($self,$soap,$other) = @_; return('Original soap message: '.$soap); } 1;
I'm testing it with the following code:
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?

Update

A workaround could be if I change the test code (and the message sent) like this:

$soap_req =~ s/</&lt;/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?


In reply to Soap message turns to hash reference by lmocsi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.