Loading ...
Sorry, an error occurred while loading the content.

Re: [soaplite] Why does Soap::Lite stop parsing this response?

Expand Messages
  • Wes Malone
    It turns out SOAP::Lite was Doing The Right Thing. I d overlooked a note in the service docs that that said ... What I thought was just a trace output
    Message 1 of 4 , Nov 9, 2009
    • 0 Attachment
      It turns out SOAP::Lite was Doing The Right Thing. I'd overlooked a
      note in the service docs that that said

      >Note: The special characters inside <ns:return> tag are encoded to entities. (e.g. an xml return >value will contain < characters, which will be encoded to < entities) Therefore entity decoding >is needed on the client side.

      What I thought was just a trace output inconsistency was actually the
      problem. SOAP::Lite being nice and unescaping the entities before they
      ended up in the Dumper confused me as well. I originally included the
      documentation's example because it was already formatted nicely.
      Here's the actual output:
      >
      > <?xml version='1.0' encoding='utf-8'?>
      > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      >    <soapenv:Body>
      >       <ns:getVersionInfoResponse xmlns:ns="http://webservice.jchem.chemaxon">
      >          <ns:return>
      >             <Info>
      >             <JChem>
      >             <Version>5.2.6</Version>
      >             </JChem>
      >             <Java>
      >             <Vendor>Sun Microsystems Inc.</Vendor>
      >             <VmName>Java HotSpot(TM) Client VM</VmName>
      >             <Version>1.6.0_05</Version>
      >             </Java>
      >             <Os>
      >             <Arch>x86</Arch>
      >             <Name>Windows XP</Name>
      >             <Version>5.1</Version>
      >             </Os>
      >             </Info>
      >          </ns:return>
      >       </ns:getVersionInfoResponse>
      >    </soapenv:Body>
      > </soapenv:Envelope>

      Plus, everyone knows < is the same as <, right? Right? ;_;

      As of now I'm parsing the string with XML::LibXML, so the question
      still stands. Can I force SOAP::Lite to parse that interior XML
      string, even though it's been escaped?

      FWIW, I'm on version 0.710.08, the newest in the Win32-Trouchelle repo.

      Thanks again,
      Wes

      On Mon, Nov 9, 2009 at 2:55 PM, Martin Busik <martin.busik@...> wrote:
      >
      > Hi,
      > which SOAP::Lite Version are you using?
      >
      > I've tried your example with 0.69 as well as with 0.710.10.
      >
      > The result of the 0.69 differs from the result of 0.710.10, but also differs
      > from your code.
      > (The difference between 0.69 and 0.710.10 is, that in 0.710.10 there is an
      > instance of SOAP::Data for
      > every xml element returned, i.e. for JChem, Os, Java etc, where the 0.69
      > returned just getVersionInfoResponse as
      > a SOAP::Data instance)
      >
      > Cheers,
      > Martin
      >
      >
      > > -----Ursprüngliche Nachricht-----
      > > Von: soaplite@yahoogroups.com
      > > [mailto:soaplite@yahoogroups.com] Im Auftrag von Wes Malone
      > > Gesendet: Montag, 9. November 2009 01:47
      > > An: soaplite@yahoogroups.com
      > > Betreff: [soaplite] Why does Soap::Lite stop parsing this response?
      > >
      > > I'm trying to write a simple SOAP client.  After making a request, the
      > > response only seems to be parsed into perl data structure a couple
      > > levels down.  After that it's just a string of the remaining XML. I
      > > feel like it would be really kludgy to take that string and parse it
      > > manually with another XML parser.
      > >
      > > >     my $response = $soap->getVersionInfo;
      > > >     my $data = $response->dataof('//getVersionInfoResponse');
      > >
      > >
      > > The SOAP response looks like this in the trace:
      > >
      > > >     <?xml version='1.0' encoding='utf-8'?>
      > > >     <soapenv:Envelope
      > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      > > >       <soapenv:Body>
      > > >         <ns:getVersionInfoResponse
      > > xmlns:ns="http://webservice.jchem.chemaxon">
      > > >           <ns:return>
      > > >             <Info>
      > > >               <JChem>
      > > >                 <Version>5.2.1</Version>
      > > >               </JChem>
      > > >               <Java>
      > > >                 <Vendor>Sun Microsystems Inc.</Vendor>
      > > >                 <VmName>Java HotSpot(TM) Server VM</VmName>
      > > >                 <Version>1.6.0_06</Version>
      > > >               </Java>
      > > >               <Os>
      > > >                 <Arch>x86</Arch>
      > > >                 <Name>Windows XP</Name>
      > > >                 <Version>5.1</Version>
      > > >               </Os>
      > > >             </Info>
      > > >           </ns:return>
      > > >         </ns:getVersionInfoResponse>
      > > >       </soapenv:Body>
      > > >     </soapenv:Envelope>
      > >
      > > But what gets parsed into $data looks like this:
      > >
      > > >     \bless( {
      > > >         _attr => {},
      > > >         _name => "getVersionInfoResponse",
      > > >         _prefix => "ns",
      > > >         _signature => [],
      > > >         _uri => "http://webservice.jchem.chemaxon",
      > > >         _value => [
      > > >           {
      > > >             return =>
      > > "<Info>\n<JChem>\n<Version>5.2.6</Version>\n</JChem>\n<Java>\n
      > > <Vendor>Sun Microsystems Inc.</Vendor>\n<VmName>Java
      > > HotSpot(TM) Client
      > > VM</VmName>\n<Version>1.6.0_05</Version>\n</Java>\n<Os>\n<Arch
      > > >x86</Arch>\n<Name>Windows
      > > XP</Name>\n<Version>5.1</Version>\n</Os>\n</Info>\n"
      > > >           }
      > > >         ]
      > > >       }, 'SOAP::Data' )
      > >
      > > This is a simple example, but for more complex responses, it could
      > > become a huge hassle to have to parse out that XML.
      > >
      > > I found this post
      > > (http://tech.groups.yahoo.com/group/soaplite/message/2641) on the
      > > mailing list (from 2003!) that had a worrisome quote on it:
      > >
      > > >  Keep in mind the requirement that any
      > > >  attributes not natively known to SOAP
      > > >  must be namespace-qualified.
      > >
      > > And I noticed that everything that wasn't getting parsed was not
      > > namespaced.  Is there a way to force SOAP::Lite to parse that
      > > non-namespaced xml?  Is that even the problem?
      > >
      > > Thanks,
      > > Wes
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      > >
      >
    • Martin Busik
      Hi Wes, ... No. If the XML-Schema-Type of the result element is string , then SOAP::Lite (as well as other WS-packages) can treat it as a string only. Cheers,
      Message 2 of 4 , Nov 13, 2009
      • 0 Attachment
        Hi Wes,

        > As of now I'm parsing the string with XML::LibXML, so the question
        > still stands. Can I force SOAP::Lite to parse that interior XML
        > string, even though it's been escaped?

        No. If the XML-Schema-Type of the result element is "string", then
        SOAP::Lite
        (as well as other WS-packages) can treat it as a string only.

        Cheers,
        Martin
      Your message has been successfully submitted and would be delivered to recipients shortly.