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

4304Re: [soaplite] How to parse "multiRef" style responses...?

Expand Messages
  • Duncan Cameron
    Jan 7, 2005
      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
      > <alienKeys href="#id0"/>
      > </ns1:notifyAddNodeWithValuesResponse>
      > <multiRef id="id0" soapenc:root="0"
      > <item href="#id1"/>
      > <item href="#id2"/>
      > </multiRef>
      > <multiRef id="id1" soapenc:root="0"
      >xsi:type="ns3:StringPair" xmlns:ns3="urn:Grapevine"
      > <name xsi:type="xsd:string">Press.Net Content ID</name>
      > <value xsi:type="xsd:string">672835</value>
      > </multiRef>
      > <multiRef id="id2" soapenc:root="0"
      >xsi:type="ns4:StringPair" xmlns:ns4="urn:Grapevine"
      > <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
      >extract the fields I want (since this has been successful elsewhere)
      >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
      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";
    • Show all 2 messages in this topic