"opParams" option for WSService

Tuesday, May 6, 2008

The option "opParams" is an optional parameter to the WSService. If you set opParams to WSMESSAGE the service function would be like this,

/* this is the service function */
function echoFunction($inMessage /* with the type of WSMessage */) {

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


return $outMessage; /* with the type of WSMessage */
}

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


$opParams = array("echoFunction" => "WSMESSAGE");
/* WSMESSAGE is the default value for this situation */

$service = new WSService(array(


"opParams" => $opParams,

"operations" => $operations))

Note that when you provide WSMESSAGE to the "opParams", the service operation parameters(both input and output) are of the type WSMessage.
Now say we put "MIXED" in there like the one in following
/* this is the service function */
function echoFunction($inMessage /* with the type of string */) {

$outMessage = $inMessage;

return $outMessage; /* with the type of String */
}

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


$opParams = array("echoFunction" => "MIXED");
/* MIXED is the default value for this situation */

$service = new WSService(array(

"wsdl" => "http://localhost/echostring.wsdl",
"opParams" => $opParams,

"operations" => $operations))

Here note the difference in the service operation. Now the argument types are strings. This types are defined in the wsdl which is provided as an argument to the WSService.

So it is clear

When "wsdl" is provided the opParams are default to "MIXED",
otherwise it is default to "WSMESSAGE".

So you don't need to provide the opParams option explicitly in both above cases.

No comments: