Remote Procedure Calls with PEAR::XML-RPC - Inside the Function
(Page 9 of 12 )
The internal function will be passed the XML-RPC message object when called so it's necessary to be able to gain access to the each argument. Calling getParam against the message to the requested value does this. If the requested parameter doesn't exist then getParam will return undef.
<?php $name1 = $msg->getParam(0); $name2 = $msg->getParam(1); ?> |
The getParam method returns a value object so the actual value needs to be obtained using the scalarvar, arraymem and structmem methods discussed earlier.
<?php $length = strlen($name1->scalarval() . $name2->scalarval()); ?> |
After performing the function specific tasks and a result is ready to go, it's packed up as an value object and returned as an response object by XML_RPC_Response.
<?php $result = new XML_RPC_Value( $length, "int"); return new XML_RPC_Response($result); ?> |
Next: Map and Send >>
More Miscellaneous Articles
More By bluephoenix