Thread

Posted on Mon Jun 4 11:59:11 2007 by saru
Accessing return value using SOAP::Lite library
Hi, I am facing difficulty in accessing the return value in the client for a web service call. The client is written using SOAP::Lite library, and the web service is hosted in Java / AXIS 1.3 SOAP 1.1 server
Below is the code snip on how I am trying to access the return value
... Code snip starts ....
my $method = SOAP::Data->name('ns0:in0') ->attr({'xmlns:ns0' => 'http://updateDataRequestImpl.datasynchronization.services.group.com'}); my $params = SOAP::Data->prefix ('ns0') ->attr ({'xmlns:ns0' => 'http://updateDataRequestImpl.datasynchronization.services.group.co +m'}) ->value( SOAP::Data->prefix ('ns1') ->name('TableName' => 'ProfileDB') ->attr ({'xmlns:ns1' => 'http://datasynchronization.services.group.com'}) ->type (''), ... ... ); my $result; $result = $soap->call($method => $params) ->result; print "$result";
... Code snip ends ....
The web server call is successful and on debug, I can see the response XML as below ...
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <updateDataRequestReturn xmlns="http://updateDataRequestImpl.datasynchronization.services.group.com +">false</updateDataRequestReturn> </soapenv:Body> </soapenv:Envelope>
But I am unable to access the return value (i.e. 'false') in $result variable in the above program.
Can anyone help me in this ?
Thanks in advance !!
Regards,
Saravanan
Direct Responses: 5327 | Write a response
Posted on Wed Jun 6 06:29:15 2007 by saramic in response to 5307
Re: Accessing return value using SOAP::Lite library
presumably you have run Data::Dumper on your result ($result) to show that it is a SOAP::SOM object
use Data::Dumper; print Dumper $result;
if all is well then I do not see why
print $result->result
should not print result. That said, I am not familiar with the way you are calling, ie.
$result = $soap->call($method => $params) print $result->result
I have changed you code a little to get at the $result object which should be of type SOAP::SOM if the result call above does not work you should be able to do the following
my ($returnValue) = @{$result->method}{qw(updateDataRequestReturn)}
this will get the "updateDataRequestReturn" tag contents from the SOAP envelope (XML). More completely I would think that your client should be written as follows:
my $result = SOAP::Lite ->uri('http://updateDataRequestImpl.datasynchronization.services.group.com') ->proxy('<URL OF YOUR END POINT>') ->method($params); print $result->result; my ($returnValue) = @{$result->method}{qw(updateDataRequestReturn)} print $returnValue
hope that helps Michael
Write a response