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

3356Problem decoding a message...

Expand Messages
  • Paul Harman
    Feb 12 8:19 AM
    • 0 Attachment
      I have a problem trying to write a SOAP::Lite client to decode the following
      response from a (gSOAP) server:


      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      xmlns:gvip="urn:GrapevineSubsystem"
      xmlns:gv="urn:Grapevine"
      >
      <SOAP-ENV:Body
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><gv:getNo
      deFieldsFromIDResponse>
      <nodeInfo xsi:type="gv:MapStringString">
      <item xsi:type="gv:StringPair">
      <name>label</name>
      <value>SCIENCE Cloning</value>
      </item>
      <item xsi:type="gv:StringPair">
      <name>plainText</name>
      <value>Researchers have successfully cloned a human
      embryo to extract stem cells in what was hailed today as a major step
      forward for medical science.</value>
      </item>
      </nodeInfo>
      </gv:getNodeFieldsFromIDResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>


      I'm using the following code to decode this:

      my $r=$res->result;
      foreach my $k (keys %{$r})
      {
      foreach my $k2 (keys %{${$r}{$k}})
      {
      print "$k2 = ${${$r}{$k}}{$k2}\n";
      }
      }

      A bit ugly, but that seems to be how SOAP::Lite is attempting to decode
      this. Unfortunately it seems to want to de-serialise gv:MapStringString as a
      hash with just a single <item> in it, rather than as an array of <item>s,
      which would make more sense.

      So my code only ever prints out "plainText = Researchers..."; the 'label'
      parameter is lost.

      Is this a problem with the way gv:MapStringString is defined (i.e. not
      explicitly stated to be an array)? There's nothing I can do about this
      server-side, so is there a way to influence SOAP::Lite's decoding behaviour?

      Thanks in advance,

      Paul


      This E-Mail and any attachment is intended only for the person or entity for
      which it is addressed and may contain confidential material. If you are not
      the addressee or have received this E-Mail in error, please inform the
      sender immediately and delete it from your computer. In addition, if you are
      not the addressee or have received this E-Mail in error, any disclosure,
      copying, distribution or any action taken or omitted to be taken in reliance
      upon it is prohibited and may be unlawful.
      If this E-Mail has been transmitted outside the ordinary course of its
      business, the company for which the sender works accepts no liability for
      any loss or damage suffered by any person arising from any use of or
      reliance on information contained in this E-Mail, and any opinion expressed
      in this E-Mail is personal to the sender and may not reflect the opinion of
      such company. Although the network operator makes every reasonable effort to
      keep its network free from viruses, neither the network operator nor the
      sender or the company for which the sender works accepts any responsibility
      for computer viruses transmitted through this E-Mail or any attachments; it
      is your responsibility to virus scan this E-Mail and any attachments. Any
      E-Mail reply to this address may be subject to interception or monitoring
      for operational reasons or for lawful business practices.
    • Show all 2 messages in this topic