yoyoyo
yoyoyo

Reputation: 17

array to string conversion error during consuming a web service using php,soap,wsdl

I am trying a simple web service in php,soap and wsdl using Nusoap toolkit . The sum function is correctly registered at server.php and the web service is already created however, to consume the service using client.php it shows the following error message:

Notice: Array to string conversion in C:\wamp\www\my\client.php on line 6. Thank you for sharing your experience.

service.php

<?php

function sum($number1,$number2)    
{       
   $result= $number1+$number2;    
    return $result;    
}

?>

client.php

<?php

require('lib/nusoap.php');

        $client=new nusoap_client("http://localhost/my/server.php?wsdl");

$value1=200;

$value2=300;
  $result=$client->call('sum',array('number1'=>"$value1",'number2'=>"$value2"));

echo $result;

?>

Upvotes: 1

Views: 2269

Answers (1)

BobbyTables
BobbyTables

Reputation: 4705

First, its a notice, and therefore does not "hinder" the execution, so it probably works, but if outputting the notice is a problem you can turn that off

error_reporting(E_ERROR);

Second, the source of the notice might come from $result being an array, and echo expects a string, or maybe your "call" expects a string as second parameter. Is it line 6 you have shown us?

EDIT: if you want to echo just the result, you need to take a look at the result array:

print_r($result);

and from that determine where in the array the result is, for example;

echo $result['sum'];

or just look at whatever is creating the array to see how its structured

Upvotes: 1

Related Questions