Introduction to Zend\XmlRpc

From its home page, XML-RPC is described as a ”...remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned.”

Zend Framework provides support for both consuming remote XML-RPC services and building new XML-RPC servers.

Quick Start

To show how easy is to create XML-RPC services with Zend\XmlRpc\Server, take a look at the following example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Greeter
{

    /**
    * Say hello to someone.
    *
    * @param string $name Who to greet
    * @return string
    */
    public function sayHello($name='Stranger')
    {
        return sprintf("Hello %s!", $name);
    }
}

$server = new Zend\XmlRpc\Server;
// Our Greeter class will be called
// greeter from the client
$server->setClass('Greeter', 'greeter');
$server->handle();

Note

It is necessary to write function and method docblocks for the services which are to be exposed via Zend\XmlRpc\Server, as it will be used to validate parameters provided to the methods, and also to determine the method help text and method signatures.

An example of a client consuming this XML-RPC service would be something like this:

1
2
3
4
5
6
7
$client = new Zend\XmlRpc\Client('http://example.com/xmlrpcserver.php');

echo $client->call('greeter.sayHello');
// will output "Hello Stranger!"

echo $client->call('greeter.sayHello', array('Dude'));
// will output "Hello Dude!"

Table Of Contents

Previous topic

Advanced usage of helpers

Next topic

Zend\XmlRpc\Client

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Introduction to Zend\XmlRpc on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.