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

How to parse "multiRef" style responses...?

Expand Messages
  • Paul Harman
    I m getting the following response back from an Apache AXIS service:
    Message 1 of 2 , Jan 7, 2005
    View Source
    • 0 Attachment
      I'm getting the following response back from an Apache AXIS service:

      <soapenv:Body>
      <ns1:notifyAddNodeWithValuesResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="urn:GrapevineSubsystem">
      <alienKeys href="#id0"/>
      </ns1:notifyAddNodeWithValuesResponse>
      <multiRef id="id0" soapenc:root="0"
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xsi:type="ns2:MapStringString"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns2="urn:Grapevine">
      <item href="#id1"/>
      <item href="#id2"/>
      </multiRef>
      <multiRef id="id1" soapenc:root="0"
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xsi:type="ns3:StringPair" xmlns:ns3="urn:Grapevine"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <name xsi:type="xsd:string">Press.Net Content ID</name>
      <value xsi:type="xsd:string">672835</value>
      </multiRef>
      <multiRef id="id2" soapenc:root="0"
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xsi:type="ns4:StringPair" xmlns:ns4="urn:Grapevine"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <name xsi:type="xsd:string">Press.Net Product ID</name>
      <value xsi:type="xsd:string">669961</value>
      </multiRef>
      </soapenv:Body>


      What I want to get out of that is a hash:

      Press.Net Content ID => 672835
      Press.Net Product ID => 669961



      I've tried using $response->dataof("//multiRef/*") and so on to try and
      extract the fields I want (since this has been successful elsewhere) but
      with no luck. Maybe I was doing it all wrong.

      If anyone has any ideas, please let me know... even if it's to tell me how I
      can get the raw XML response so I can write my own regular-expression based
      extractor...

      Thanks,

      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.
    • Duncan Cameron
      ... Hi Paul You don t need to worry about the multiRefs because SOAP::Lite automatically takes them into account when deserialising the SOAP envelope, using
      Message 2 of 2 , Jan 7, 2005
      View Source
      • 0 Attachment
        On 2005-01-07 at 13:14:23 Paul Harman wrote:

        >I'm getting the following response back from an Apache AXIS service:
        >
        > <soapenv:Body>
        > <ns1:notifyAddNodeWithValuesResponse
        >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:ns1="urn:GrapevineSubsystem">
        > <alienKeys href="#id0"/>
        > </ns1:notifyAddNodeWithValuesResponse>
        > <multiRef id="id0" soapenc:root="0"
        >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xsi:type="ns2:MapStringString"
        >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:ns2="urn:Grapevine">
        > <item href="#id1"/>
        > <item href="#id2"/>
        > </multiRef>
        > <multiRef id="id1" soapenc:root="0"
        >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xsi:type="ns3:StringPair" xmlns:ns3="urn:Grapevine"
        >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        > <name xsi:type="xsd:string">Press.Net Content ID</name>
        > <value xsi:type="xsd:string">672835</value>
        > </multiRef>
        > <multiRef id="id2" soapenc:root="0"
        >soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xsi:type="ns4:StringPair" xmlns:ns4="urn:Grapevine"
        >xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        > <name xsi:type="xsd:string">Press.Net Product ID</name>
        > <value xsi:type="xsd:string">669961</value>
        > </multiRef>
        > </soapenv:Body>
        >
        >What I want to get out of that is a hash:
        >
        > Press.Net Content ID => 672835
        > Press.Net Product ID => 669961
        >
        >I've tried using $response->dataof("//multiRef/*") and so on to try
        >and
        >extract the fields I want (since this has been successful elsewhere)
        >but
        >with no luck. Maybe I was doing it all wrong.
        >
        >If anyone has any ideas, please let me know... even if it's to tell
        >me how I
        >can get the raw XML response so I can write my own regular-
        >expression based
        >extractor...
        >
        Hi Paul

        You don't need to worry about the multiRefs because SOAP::Lite
        automatically takes them into account when deserialising the SOAP
        envelope, using the #id0, #id1 etc. ids.

        try something like this:

        my $som = $soap->method(...);
        my $r = $som->result;

        my @item = @{$r->{item}};
        for (@item) {
        print $_->{name}, ' ', $_->{value}, "\n";
        }
        Regards
        Duncan
      Your message has been successfully submitted and would be delivered to recipients shortly.