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

Re: [soaplite] how to retrieve the result from a soap call

Expand Messages
  • Lee Carmichael
    Hello, In your example, $ret is really a soap response object (SOM) unless something happened to cause an exception (die or croak) to occur. You can read the
    Message 1 of 2 , Apr 6 10:01 AM
    • 0 Attachment
      Hello,

      In your example, $ret is really a soap response object (SOM) unless something happened to cause an exception (die or croak) to occur. You can read the data access methods in: http://search.cpan.org/perldoc?SOAP::SOM

      But in general you can use XPath methods to retrieve data. Here is an example:

         my $resp= $soap->call( $method => @params); # changed ret to resp

         die "Fault occurred: " . $resp->faultstring if $resp && $resp->fault;
        
         # grab data from response
         print "Cat: " . $resp->match('//cat') if $resp->match('//cat'); ## not a great example...

      In your example the 'result' method will only return the data in a method Response block. This is kind of confusing but basically the server needs to return something that looks like:

      <soap:Body><methodResponse>...data here...</methodResponse></soap:Body>

      If it doesn't then the 'result' method will return undef even though there might a SOAP repsonse with data from your service. Otherwise, you can grab the other data in the SOAP response with the method above.

      HTH,

      Lee




      it returns a correct XML response.
      how every if i call it the following way, it prompt that the result method is not found:

      my $ret= $soap->call( $method => @params)
      ->result;
      Can't call method "result" without a package or object reference at /path/to/module. pm line 101.

      I am very new to SOAP::Lite, and i see examples from SOAP::Lite are doing it this way, but it seems not work for me.

      Can anybody help me on this?
      Thank you very much.

    Your message has been successfully submitted and would be delivered to recipients shortly.