1 <?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
2 <head><title>xmlrpc - Proxy demo</title></head>
5 <h2>Query server using a 'proxy' object</h2>
6 <h3>The code demonstrates usage for the terminally lazy. For a more complete proxy, look at at the Wrapper class</h3>
7 <p>You can see the source to this page here: <a href="proxy.php?showSource=1">proxy.php</a></p>
13 protected $prefix = 'examples.';
15 public function __construct(PhpXmlRpc\Client $client)
17 $this->client = $client;
21 * Translates any method call to an xmlrpc call.
25 * @param string $name remote function name. Will be prefixed
26 * @param array $arguments
32 public function __call($name, $arguments)
34 $encoder = new PhpXmlRpc\Encoder();
35 $valueArray = array();
36 foreach ($arguments as $parameter) {
37 $valueArray[] = $encoder->encode($parameter);
40 // just in case this was set to something else
41 $this->client->return_type = 'phpvals';
43 $resp = $this->client->send(new PhpXmlRpc\Request($this->prefix.$name, $valueArray));
45 if ($resp->faultCode()) {
46 throw new Exception($resp->faultString(), $resp->faultCode());
48 return $resp->value();
53 $stateNo = rand(1, 51);
54 $proxy = new PhpXmlRpcProxy(new PhpXmlRpc\Client(XMLRPCSERVER));
55 $stateName = $proxy->getStateName($stateNo);
57 echo "State $stateNo is ".htmlspecialchars($stateName);
59 require_once __DIR__ . "/_append.php";