login button

Two functions in server

Forums :

Hi,

I have been looking at the samples code.
In the first sample the code of the server is:
$requestPayloadString = <<

Hello World!

XML;

function echoFunction($inMessage) {

$outMessage = new WSMessage($inMessage->str);

return $outMessage;
}

$operations = array("echoString" => "echoFunction");

$service = new WSService(array("operations" => $operations));

$service->reply($requestPayloadString);

?>

And The code of the client is:

$requestPayloadString = <<Hello World!
XML;

try {

$client = new WSClient(array( "to" => "http://localhost/samples/echo_service.php" ));

$responseMessage = $client->request( $requestPayloadString );

printf("Response = %s
", htmlspecialchars($responseMessage->str));

} catch (Exception $e) {

if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->Reason);
} else {
printf("Message = %s\n",$e->getMessage());
}

}
?>

But I haven't looked in the client where is the call at the function "echo client", because I want put two functions in the server and sometimes I'll call at the first function and other times I'll call at the second function.

I need help

Thank you

Regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Set multiple entries in the operations array

You can set multiple entries in the operations array like this.

function anotherFunction($message) {
....
}

$operations = array("echoString" => "echoFunction",
"anotherOperation" => "anotherFunction");

$svr = new WSService($operations);
$svr->reply();

Hope you get the point.

Thanks
Dimuthu

doubts about the client

Hi

Thank you for ypur answer.
I Understand that i have.
function FunctionA($message) {
....
}

function FunctionB($message) {
....
}

function FunctionC($message) {
....
}

$operations = array("functionA" => "FunctionA",
"functionB" => "FunctionB","functionC" => "FunctionC");

$svr = new WSService($operations);
$svr->reply();

This is correct no?

But when you are in the client, how you do the call at the function?
From the client how you calling the FunctionA,FunctionB, FunctionC...

Thank you

Regards

yea, that way is

yea, that way is correct.

for client

$client = new WSClient(...);

$xml1 = <<

XML

$res1 = $client->request($xml1);

$xml2 = <<

XML

$res1 = $client->request($xml2);

you can continue calling request method as many..

Thanks
Dimuthu

Hi, You say : $client = new

Hi,

You say :

$client = new WSClient(...);

$xml1 = <<

XML

$res1 = $client->request($xml1);

$xml2 = <<

XML

$res1 = $client->request($xml2);

But the unique difference is xml1 and xml2.
xml1 reference FunctionA and xml2 reference FunctionB.
Sorry but I don't see exactly the diferrence.
For example with nusoap is:
$client->("FunctionA",$paramsA);
$client->("FunctionB",$paramsB);
...

Thank you
Regards

I think what you ask is how

I think what you ask is how to identify the corresponding operation. We use the term dispatching for that. There are several ways server can dispatch, using action, using wsa action but you can simply use the body based dispatching, there your xml1 will be something like
<functionA>
...
</functionA>

and xml2 will be,
<functionB>
...
</functionB>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.