## Class Ripcord_Server

Description

This class implements the Ripcord server. It is an OO wrapper around PHP's XML-RPC methods, with some added features.

You can create an XML-RPC (or Simple RPC or a simple SOAP 1.1) server by defining a class with public methods and passing an object (or array of objects) of this class to the constructor of Ripcord_Server. Then simply call the run() method.

A basic example:

1. <?php
2. $myObject = new MyClass();
3. $server = ripcord::server( $myObject );
4. $server->run();
5. ?>

An example with namespaces in the method names and a static class as rpc service.

1. <?php
2. $myObject = new MyClass();
3. $server = ripcord::server(
4. array(
5. 'namespace1' => $myObject,
6. 'namespace2' => 'myOtherClass'
7. )
8. );
9. $server->run();
10. ?>

You don't need to instantiate a class to use it with Ripcord, in the above example 'myOtherClass' is the name of a PHP class to use. In addition you may also specify functions or methods directly, in any format that matches PHP's is_callable() criteria.

Located in /ripcord_server.php (line 49)

Method Summary
Ripcord_Server __construct ([ $services = null], [ $options = null], [ $documentor = null], mixed $services., array $options.)
void addMethod (string $name, callback $method)
void addService (object $service, [string $serviceName = 0])
mixed call (string $method, [array $args = null])
string handle (string $request_xml)
void run ()
void setOutputOption (string $option, mixed $value)
Methods
Constructor __construct (line 97)

Creates a new instance of the Ripcord server.

- see: Ripcord_Server::setOutputOption()
- throws: Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service
- throws: Ripcord_ConfigurationException (ripcord::xmlrpcNotInstalled) when the xmlrpc extension in not available.

Ripcord_Server __construct ([ $services = null], [ $options = null], [ $documentor = null], mixed $services., array $options.)

- mixed $services.: Optional. An object or array of objects. The public methods in these objects will be exposed through the RPC server. If the services array has non-numeric keys, the key for each object will define its namespace.
- array $options.: Optional. Allows you to override the default server settings. Accepted key names are:
  - 'documentor': allows you to specify an alternative HTML documentor class, or if set to false, no HTML documentor.
  - 'name' : The name of the server, used by the default HTML documentor.
  - 'css' : An url of a css file to link to in the HTML documentation.
  - 'wsdl' : The wsdl 1.0 description of this service (only usefull if you run the 'soap 1.1' version, or the 'auto' version
  - 'wsdl2' : The wsdl 2.0 description of this service
  In addition you can set any of the outputOptions for the xmlrpc server.
- $services
- $options
- $documentor

addMethod (line 185)

Allows you to add a single method to the server after construction.

- access: public

void addMethod (string $name, callback $method)

- string $name: The name of the method as exposed through the rpc server
- callback $method: The name of the method to call, or an array with classname or object and method name.

addService (line 134)

Allows you to add a service to the server after construction.

- throws: Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service
- access: public

void addService (object $service, [string $serviceName = 0])

- object $service: The object or class whose public methods must be added to the rpc server. May also be a function or method.
- string $serviceName: Optional. The namespace for the methods.

call (line 340)

Calls a method by its rpc name.

- throws: Ripcord_BadMethodCallException (ripcord::methodNotFound) when the requested method isn't available.
- throws: Ripcord_InvalidArgumentException (ripcord::cannotRecurse) when passed a recursive multiCall
- access: public

mixed call (string $method, [array $args = null])

- string $method: The rpc name of the method
- array $args: The arguments to this method

handle (line 301)

Handles the given request xml

- access: public

string handle (string $request_xml)

- string $request_xml: The incoming request.

run (line 197)

Runs the rpc server. Automatically handles an incoming request.

- access: public

void run ()
setOutputOption (line 382)

Allows you to set specific output options of the server after construction.

- access: public

void setOutputOption (string $option, mixed $value)

- string $option: The name of the option
- mixed $value: The value of the option The options are:
  - output_type: Return data as either php native data or xml encoded. Can be either 'php' or 'xml'. 'xml' is the default.
  - verbosity: Determines the compactness of generated xml. Can be either 'no_white_space', 'newlines_only' or 'pretty'. 'pretty' is the default.
  - escaping: Determines how/whether to escape certain characters. 1 or more values are allowed. If multiple, they need to be specified as a sub-array. Options are: 'cdata', 'non-ascii', 'non-print' and 'markup'. Default is 'non-ascii', 'non-print' and 'markup'.
  - version: Version of the xml vocabulary to use. Currently, three are supported: 'xmlrpc', 'soap 1.1' and 'simple'. The keyword 'auto' is also recognized and tells the server to respond in whichever version the request cam in. 'auto' is the default.
  - encoding: The character encoding that the data is in. Can be any supported character encoding. Default is 'utf-8'.

Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3