Reputation: 11592
I want to call a soap web service written asp.net(C#).Actually,the web method takes one string as a parameter and return some string as output.
In client side(PHP) am using nusoap for accessing web service.
This is php code to calling my web service...
<?php
require_once('nusoap/lib/nusoap.php');
$wsdl="http://localhost/suppliers.asmx?WSDL";
$param=array('name'=>'saran');
$client = new soapclient($wsdl,'wsdl');
echo $client->call('ShowSuppliers',$param);
?>
But when i run this code, the echo statement simply displaying Array in the browser...
I don't know what is the problem here...
But when i tried to follow the Broncha approach something like this, it's working good...
Instead of directly using the echo statement, i tried like this
$result=$client->call('ShowSuppliers',$param);
foreach($result as $key => $value)
{
echo $value;
}
What is the difference between these two's...
Please guide me to get out of this problem...
Upvotes: 1
Views: 1144
Reputation: 2190
$client->call('ShowSuppliers',$param); returns you an Array element so whenever you echo an array element it is seen as Array written in the browser. To print an Array either you can use print_r(array name) or var_dump(array name);.
In the next code you are using foreach loop so it is parsing the array element into key and value pair..
Please dont used call('ShowSuppliers',$param); because call function has been deprecated please see the link http://php.net/manual/en/soapclient.call.php
Instead use soapCall function please see the link http://php.net/manual/en/soapclient.soapcall.php
It might create problem later onwards since the function is deprecated.
Upvotes: 2