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

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

Expand Messages
  • Duncan Cameron
    Jan 7, 2005
    • 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
    • Show all 2 messages in this topic