Simple calculator
This simple calculator application sends two integer values to the server.
The server adds these numbers and returns the result. This shows how you can
add parameters to your request and how eZ soap™ handles the data types.
Sending request parameters
You can add request parameters with the addParameter function.
$request->addParameter( "valueA", 42 );
$request->addParameter( "valueB", 17 );
Server handling of parameters
On the server you have to register the function with the parameters and the types for the
parameters. Since PHP is a loosely typed language we also have to set the type of the return
value so that eZ soap™ knows what type to encode the response as.
include_once( "lib/ezsoap/classes/ezsoapserver.php" );
$server = new eZSOAPServer( );
$server->registerFunction( "addNumbers", array( "valueA" => "integer", "valueB" => "integer" ) );
$server->processRequest();
function addNumbers( $valueA, $valueB )
{
$return = $valueA + $valueB;
settype( $return, "integer" );
return $return;
}
|