1

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;

?>

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

@yoyoyo updated answer with details on how to find out
@yoyoyo then you should mark this as the answer with the checkbox :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.