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.619. 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.620. XmlRpcClient Default, but Overridable Headers
Header | Default Value |
---|---|
|
|
|
|
|
|
|
|
Table 4.621. 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. |
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.
new XmlRpcClient([opts, noconnect]
)
$xrc = new XmlRpcClient(("url":"http://hostname/RPC2"));
Table 4.622. Arguments for XmlRpcClient::constructor()
Argument |
Type |
Description |
---|---|---|
|
Hash |
an option hash, see HTTPClient::constructor() Option Hash Keys for valid keys in this hash. |
| Boolean | If this optional argument is passed with a value of True, then the object will not attempt to make a connection immediately to the remote socket, but instead will wait until a connection is required or manually established with the parent class' HTTPClient::connect() method. |
Table 4.623. Return Values for XmlRpcClient::constructor()
Return Type |
Description |
---|---|
Object |
The XmlRpcClient object is returned |
Destroys the XmlRpcClient object and closes any open connections.
delete lvalue
delete $xrc;
Table 4.624. Arguments for XmlRpcClient::destructor()
Argument |
Type |
Description |
---|---|---|
n/a |
n/a |
This method takes no arguments. |
Table 4.625. Return Values for XmlRpcClient::destructor()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Copying objects of this class is not supported, an exception will be thrown.
Table 4.626. Arguments for XmlRpcClient::copy()
Argument |
Type |
Description |
---|---|---|
n/a |
n/a |
This method takes no arguments. |
Table 4.627. Return Values for XmlRpcClient::copy()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Table 4.628. 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(method_name, [args...]
)
$result = $xrc.call("method.name", $arg1, $arg2);
Table 4.629. Arguments for XmlRpcClient::call()
Argument |
Type |
Description |
---|---|---|
|
String |
The XML-RPC method name to call |
|
Any |
Optional arguments for the method. |
Table 4.630. Return Values for XmlRpcClient::call()
Return Type |
Description |
---|---|
Hash |
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(method_name, [arg_list]
)
$result = $xrc.callArgs("method.name", $arg_list);
Table 4.631. Arguments for XmlRpcClient::callArgs()
Argument |
Type |
Description |
---|---|---|
|
String |
The XML-RPC method name to call |
|
List or Any |
An optional list (or single value) of arguments for the method. |
Table 4.632. Return Values for XmlRpcClient::callArgs()
Return Type |
Description |
---|---|
Hash |
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(lvalue_ref, method_name, [args...]
)
$result = $xrc.callWithInfo(\$info, "method.name", $arg1, $arg2);
Table 4.633. Arguments for XmlRpcClient::callWithInfo()
Argument |
Type |
Description |
---|---|---|
| LValue Reference | 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 JSON-RPC call. |
|
String |
The XML-RPC method name to call |
|
Any |
Optional arguments for the method. |
Table 4.634. Return Values for XmlRpcClient::callWithInfo()
Return Type |
Description |
---|---|
Hash |
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(lvalue_ref, method_name, [arg_list]
)
$result = $xrc.callArgsWithInfo(\$info, "method.name", $arg_list);
Table 4.635. Arguments for XmlRpcClient::callArgsWithInfo()
Argument |
Type |
Description |
---|---|---|
| LValue Reference | 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 JSON-RPC call. |
|
String |
The XML-RPC method name to call |
|
List or Any |
An optional list (or single value) of arguments for the method. |
Table 4.636. Return Values for XmlRpcClient::callArgswithInfo()
Return Type |
Description |
---|---|
Hash |
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. |