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

Re: [soaplite] How the heck do i access an object returned as a result?

Expand Messages
  • Eric Bridger
    See: http://www.majordojo.com/archives/cat_soaplite_solutions.html There is a section Parsing a result object from SOAP::Lite which explains that the
    Message 1 of 2 , Dec 12, 2007
    • 0 Attachment
      See:
      http://www.majordojo.com/archives/cat_soaplite_solutions.html

      There is a section "Parsing a result object from SOAP::Lite" which
      explains that the $result is a SOM object on which you can use XPath
      type expressions to access the data.
      To quote some of that post:
      ================
      Let's say that the SOAP Envelope returned contained an array. How
      would you iterate over each element of that array? Like so:

      for my $t ($som->valueof('//catalog/product')) {
      print $t->{title} . " - " . $t->{our_price} . "\n";
      }
      =============
      I this example $som = $result in your case.
      You may have to do $c->want_som(1); to ensure you get a SOM from you
      request.

      Eric

      On Dec 8, 2007, at 1:06 PM, Chuck Cochems wrote:

      > I have this soap API i'm trying to talk to.
      >
      > And it likes to return blessed references as results...
      >
      > and I can't for the LIFE of me figure out how to get at the arrays
      > and hashes it returns!
      >
      > Here's an example.
      >
      > $result = $c->GetLineConfigData($id,$key,"testuser",5107960603);
      > # print Dumper ($result);
      > unless ($result->fault) {
      > print $result->result();
      > print "\n";
      > print $result->paramsout();
      > print "\n";
      > } else {
      > print join ', ',
      > $result->faultcode,
      > $result->faultstring;
      > }
      > print "\n";
      >
      > now what happens when I try to print the result?
      >
      > WarningArray=ARRAY(0x88591a4)
      > LineConfigData=HASH(0x8858a9c)
      >
      > If i'm reading this right, $result and $paramsout now contain a
      > reference to an object named WArningArray, which is an array, and an
      > object named LineConfigData, which is a hash. Yet I have been
      > completely unable to get at the data inside those objects! A simple
      > defererence attempt seems to do nothing.
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.