xmlrpcmsg

This class provides a representation for a request to an XML-RPC server. A client sends an xmlrpcmsg to a server, and receives back an xmlrpcresp (see xmlrpc_client->send).

Creation

The constructor takes the following forms:

xmlrpcmsgnew xmlrpcmsg(string$methodName,
 array$parameterArraynull);
 

Where methodName is a string indicating the name of the method you wish to invoke, and parameterArray is a simple php Array of xmlrpcval objects. Here's an example message to the US state name server:


$msg = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23"int")));

This example requests the name of state number 23. For more information on xmlrpcval objects, see xmlrpcval.

Note that the parameterArray parameter is optional and can be omitted for methods that take no input parameters or if you plan to add parameters one by one.

Methods

addParam

booladdParam(xmlrpcval$xmlrpcVal);
 

Adds the xmlrpcval xmlrpcVal to the parameter list for this method call. Returns TRUE or FALSE on error.

getNumParams

intgetNumParams(void); 
 

Returns the number of parameters attached to this message.

getParam

xmlrpcvalgetParam(int$n);
 

Gets the nth parameter in the message (with the index zero-based). Use this method in server implementations to retrieve the values sent by the client.

method

stringmethod(void); 
 
stringmethod(string$methName);
 

Gets or sets the method contained in the XML-RPC message.

parseResponse

xmlrpcrespparseResponse(string$xmlString);
 

Given an incoming XML-RPC server response contained in the string $xmlString, this method constructs an xmlrpcresp response object and returns it, setting error codes as appropriate (see xmlrpc_client->send).

This method processes any HTTP/MIME headers it finds.

parseResponseFile

xmlrpcrespparseResponseFile(file handle resource$fileHandle);
 

Given an incoming XML-RPC server response on the open file handle fileHandle, this method reads all the data it finds and passes it to parseResponse.

This method is useful to construct responses from pre-prepared files (see files demo1.txt, demo2.txt, demo3.txt in this distribution). It processes any HTTP headers it finds, and does not close the file handle.

serialize

string serialize(void); 
 

Returns the an XML string representing the XML-RPC message.