proxy demo

Query server using a 'proxy' object

The code demonstrates usage for the terminally lazy. For a more complete proxy, look at at the Wrapper class

client = $client; } /** * Translates any method call to an xmlrpc call. * * @author Toth Istvan * * @param string $name remote function name. Will be prefixed * @param array $arguments * * @return mixed * * @throws Exception */ function __call($name, $arguments) { $encoder = new PhpXmlRpc\Encoder(); $valueArray = array(); foreach ($arguments as $parameter) { $valueArray[] = $encoder->encode($parameter); } // just in case this was set to something else $this->client->return_type = 'phpvals'; $resp = $this->client->send(new PhpXmlRpc\Request($this->prefix.$name, $valueArray)); if ($resp->faultCode()) { throw new Exception($resp->faultString(), $resp->faultCode()); } else { return $resp->value(); } } } $stateNo = rand(1, 51); $proxy = new PhpXmlRpcProxy(new \PhpXmlRpc\Client('http://phpxmlrpc.sourceforge.net/server.php')); $stateName = $proxy->getStateName($stateNo); echo "State $stateNo is ".htmlspecialchars($stateName);