Note: This class is not available with the PO_NO_NETWORK parse option.
The XmlRpcClient class provides easy access to XML-RPC web services. This class inherits all public methods of the HTTPClient class. The inherited HTTPClient methods are not listed in this section, see the section on the HTTPClient class for more information on methods provided by the parent class. For low-level XML-RPC functions, see the XML-RPC functions in XML Functions.
The XmlRpcClient class understands the following protocols in addition to the protocols supported by the HTTPClient class:
Table 4.467. XmlRpcClient Class Protocols
Protocol | Default Port | SSL? | Description |
|---|---|---|---|
| 80 | No | Unencrypted XML-RPC protocol over HTTP |
| 443 | Yes | XML-RPC protocol over HTTP with SSL/TLS encryption |
The XmlRpcClient supplies default values for HTTP headers as follows:
Table 4.468. XmlRpcClient Default, but Overridable Headers
Header | Default Value |
|---|---|
|
|
|
|
|
|
|
|
Table 4.469. XmlRpcClient Class Method Overview
|
Method |
Except? |
Description |
|---|---|---|
|
|
Y |
Creates the XmlRpcClient object based on the parameters passed. |
|
N |
Destroys the XmlRpcClient object and closes any open connections. | |
|
Y |
Copying objects of this class is not supported, an exception will be thrown. | |
|
| Y | Calls a remote method using a variable number of arguments for the method arguments and returns the response as qore data structure. |
|
| Y | Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure. |
|
| Y | Same as the XmlRpcClient::call() except the first argument must be an lvalue reference, which is used as an output variable, where information about the HTTP request and response is written. |
|
| Y | Same as the XmlRpcClient::callArgs() except the first argument must be an lvalue reference, which is used as an output variable, where information about the HTTP request and response is written. |
|
| N | Sets a Queue object to receive HTTPClient and Socket events or clears the queue if no argument is passed. |
Creates the XmlRpcClient object based on the parameters passed and by default immediately attempts to establish a connection to the server (pass a boolean True value as the second argument to establish a connection on demand). See HTTPClient::constructor() and HTTPClient::connect() for information on possible exceptions.
XmlRpcClient::constructor(softbool $no_connect = False)
XmlRpcClient::constructor(hash $opts, softbool $no_connect = False)
my XmlRpcClient $xrc(("url":"http://hostname/RPC2"));
Table 4.470. Arguments for XmlRpcClient::constructor()
Argument | Description |
|---|---|
| an option hash, see HTTPClient::constructor() Option Hash Keys for valid keys in this hash. |
| If this optional argument is passed with a value of |
Destroys the XmlRpcClient object and closes any open connections.
delete $xrc;
Copying objects of this class is not supported, an exception will be thrown.
Table 4.471. Exceptions thrown by XmlRpcClient::copy()
|
err |
desc |
|---|---|
|
|
objects of this class may not be copied |
Calls a remote method using a variable number of arguments for the method arguments and returns the response as qore data structure. See HTTPClient::send(), makeXMLRPCCallString(), and parseXMLRPCResponse() for information on possible exceptions.
XmlRpcClient::call(string $method, ...) returns hash
$result = $xrc.call("method.name", $arg1, $arg2);
Table 4.472. Arguments for XmlRpcClient::call()
Argument | Description |
|---|---|
| The XML-RPC method name to call |
| Optional arguments for the method. |
Table 4.473. Return Values for XmlRpcClient::call()
|
Return Type |
Description |
|---|---|
|
If the call was successful, the response information will be found in the key 'params'. If an error occurred then the error information can be found under the 'fault' key. |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure. See HTTPClient::send(), makeXMLRPCCallString(), and parseXMLRPCResponse() for information on possible exceptions.
XmlRpcClient::callArgs(string $method, any $args) returns hash
$result = $xrc.callArgs("method.name", $arg_list);
Table 4.475. Return Values for XmlRpcClient::callArgs()
|
Return Type |
Description |
|---|---|
|
If the call was successful, the response information will be found in the key 'params'. If an error occurred then the error information can be found under the 'fault' key. |
Like the XmlRpcClient::call() method, except requires an lvalue reference as the first argument that will be used as an output variable providing information about the HTTP request and response made to effect the XML-RPC call.
XmlRpcClient::callWithInfo(reference $info, string $method, ...) returns hash
$result = $xrc.callWithInfo(\$info, "method.name", $arg1, $arg2);
Table 4.477. Return Values for XmlRpcClient::callWithInfo()
|
Return Type |
Description |
|---|---|
|
If the call was successful, the response information will be found in the key 'params'. If an error occurred then the error information can be found under the 'fault' key. |
Like the XmlRpcClient::callArgs() method, except requires an lvalue reference as the first argument that will be used as an output variable providing information about the HTTP request and response made to effect the XML-RPC call.
XmlRpcClient::callArgsWithInfo(reference $info, string $method, any $args) returns hash
$result = $xrc.callArgsWithInfo(\$info, "method.name", $arg_list);
Table 4.478. Arguments for XmlRpcClient::callArgsWithInfo()
Argument | Description |
|---|---|
| A reference to an lvalue that will be used as an output variable providing information about the HTTP request and response made to effect the XML-RPC call. |
| The XML-RPC method name to call |
| An optional list of arguments (or single argument) for the method. |
Table 4.479. Return Values for XmlRpcClient::callArgswithInfo()
|
Return Type |
Description |
|---|---|
|
If the call was successful, the response information will be found in the key 'params'. If an error occurred then the error information can be found under the 'fault' key. |
Sets a Queue object to receive HTTPClient and Socket events. To remove the event queue and stop monitoring events, pass NOTHING to the method. See Event Handling for more information.
XmlRpcClient::setEventQueue() returns nothing
XmlRpcClient::setEventQueue(Queue $queue) returns nothing
$xrc.setEventQueue($queue);