Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Server Proxy Object

Another way to call remote methods with the XML-RPC client is to use the server proxy. This is a PHP object that proxies a remote XML-RPC namespace, making it work as close to a native PHP object as possible.

To instantiate a server proxy, call the getProxy() instance method of Zend_XmlRpc_Client. This will return an instance of Zend_XmlRpc_Client_ServerProxy. Any method call on the server proxy object will be forwarded to the remote, and parameters may be passed like any other PHP method.

Example 1062. Proxy the Default Namespace

= new Zend_XmlRpc_Client('');

$service $client->getProxy();           // Proxy the default namespace

$hello $service->test->sayHello(12);  // test.Hello(1, 2) returns "hello"

The getProxy() method receives an optional argument specifying which namespace of the remote server to proxy. If it does not receive a namespace, the default namespace will be proxied. In the next example, the 'test' namespace will be proxied:

Example 1063. Proxy Any Namespace

= new Zend_XmlRpc_Client('');

$test  $client->getProxy('test');     // Proxy the "test" namespace

$hello $test->sayHello(12);         // test.Hello(1,2) returns "hello"

If the remote server supports nested namespaces of any depth, these can also be used through the server proxy. For example, if the server in the example above had a method, it could be called as $test->foo->bar().

Zend Framework