Qore json Module 1.8.2
|
The JsonRpcClient class provides easy access to JSON-RPC web services. More...
#include <QC_JsonRpcClient.dox.h>
Inherits HTTPClient.
Public Member Methods | |
hash | call (string method,...) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure. | |
hash | callArgs (string method, auto args) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure. | |
hash | callArgsWithInfo (reference info, string method, any args) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call. | |
hash | callId (any id, string method,...) |
Calls a remote method with a call ID, taking all arguments after the method name for the method arguments and returns the response as qore data structure. | |
hash | callIdArgsWithInfo (reference info, any id, string method, any args) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call. | |
hash | callIdWithInfo (reference info, any id, string method,...) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call. | |
hash | callWithInfo (reference info, string method,...) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call. | |
constructor () | |
Creates the JsonRpcClient object with no arguments. | |
constructor (hash opts, softbool no_connect=False) | |
Creates the JsonRpcClient object based on the parameters passed. | |
copy () | |
Throws an exception; copying JsonRpcClient objects is currently not supported. | |
string | getVersion () |
Returns the JSON-RPC protocol version. | |
nothing | setEventQueue () |
clears the event queue for the JsonRpcClient object | |
nothing | setEventQueue (Queue queue) |
sets the event queue for the JsonRpcClient object | |
nothing | setVersion (string version) |
Sets the JSON-RPC protocol version. | |
The JsonRpcClient class provides easy access to JSON-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 documentation for the HTTPClient class for more information on methods provided by the parent class. For a list of low-level JSON-RPC functions, see JSON-RPC.
Thie object supports the following JSON-RPC protocol versions:
"2.0"
: the default; requests and responses will include the "jsonrpc"
attribute assigned to the version number (this is true for any declared JSON-RPC protocol version >= 2)"1.0"
: can be explicitly set in the JsonRpcClient::constructor() or by calling JsonRpcClient::setVersion()"1.1"
version can be used as well, but support for JSON-RPC 1.1 is deprecated; for any JSON-RPC protocol version > 1.0 and < 2.0, the "version"
attribute is serialized with the declared protocol version number (unlike with 2.0 or above, where the "jsonrpc"
attribute contains this value)The JsonRpcClient class understands the following protocol schemes in addition to the protocol schemes supported by the HTTPClient class:
JsonRpcClient Class Protocols
Protocol | Default Port | SSL? | Description |
jsonrpc | 80 | No | Unencrypted JSON-RPC protocol over HTTP |
jsonrpcs | 443 | Yes | JSON-RPC protocol over HTTP with SSL/TLS encryption |
The JsonRpcClient supplies default values for HTTP headers as follows:
JsonRpcClient Default, but Overridable Headers
Header | Default Value |
Accept | text/json |
Content-Type | application/json ;charset=utf-8 |
User-Agent | Qore-JSON-RPC-Client/1.7 |
Connection | Keep-Alive |
default_path
is given in the constructor(), then "JSON"
is usedPO_NO_NETWORK
parse option. QoreValue JsonRpcClient::call | ( | string | method, |
... | |||
) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure.
method | The JSON-RPC method name to call |
... | the arguments to the call |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
id
value of 1 hash Qore::Json::JsonRpcClient::callArgs | ( | string | method, |
auto | args | ||
) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure.
method | The JSON-RPC method name to call |
args | An optional list of arguments (or single argument) for the method |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
id
value of 1 hash Qore::Json::JsonRpcClient::callArgsWithInfo | ( | reference | info, |
string | method, | ||
any | args | ||
) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call.
info | a reference to a hash that provides the following keys on output giving technical information about the HTTP call:
|
method | The JSON-RPC method name to call |
args | An optional list of arguments (or single argument) for the method |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
id
value of 1 hash Qore::Json::JsonRpcClient::callId | ( | any | id, |
string | method, | ||
... | |||
) |
Calls a remote method with a call ID, taking all arguments after the method name for the method arguments and returns the response as qore data structure.
id | the id value for the call |
method | The JSON-RPC method name to call |
... | the arguments to the call |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
hash Qore::Json::JsonRpcClient::callIdArgsWithInfo | ( | reference | info, |
any | id, | ||
string | method, | ||
any | args | ||
) |
Calls a remote method using a single value after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call.
info | a reference to a hash that provides the following keys on output giving technical information about the HTTP call:
|
id | the id value for the call |
method | The JSON-RPC method name to call |
args | An optional list of arguments (or single argument) for the method |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
hash Qore::Json::JsonRpcClient::callIdWithInfo | ( | reference | info, |
any | id, | ||
string | method, | ||
... | |||
) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call.
info | a reference to a hash that provides the following keys on output giving technical information about the HTTP call:
|
id | the id value for the call |
method | The JSON-RPC method name to call |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
id
parameter was added in json 1.7 hash Qore::Json::JsonRpcClient::callWithInfo | ( | reference | info, |
string | method, | ||
... | |||
) |
Calls a remote method taking all arguments after the method name for the method arguments and returns the response as qore data structure, accepts a reference to a hash as the first argument to give technical information about the call.
info | a reference to a hash that provides the following keys on output giving technical information about the HTTP call:
|
method | The JSON-RPC method name to call |
JSON-SERIALIZATION-ERROR | cannot serialize value passed (ex: binary, object) |
JSON-PARSE-ERROR | syntax error parsing JSON string |
HTTP-CLIENT-TIMEOUT | timeout on response from HTTP server |
HTTP-CLIENT-RECEIVE-ERROR | error communicating with HTTP server |
id
value of 1 Qore::Json::JsonRpcClient::constructor | ( | ) |
Creates the JsonRpcClient object with no arguments.
No connection is made because no connection parameters are set with this call; connection parameters must be set afterwards using the appropriate HTTPClient methods.
The JSON-RPC version is set to "2.0"
by default with this variant of the constructor()
Qore::Json::JsonRpcClient::constructor | ( | hash | opts, |
softbool | no_connect = False |
||
) |
Creates the JsonRpcClient object based on the parameters passed.
By default the object will immediately attempt to establish a connection to the server
opts | HTTPClient constructor options:
|
no_connect | pass a boolean True value argument to suppress the automatic connection and establish a connection on demand with the first request |
"version"
option Qore::Json::JsonRpcClient::copy | ( | ) |
Throws an exception; copying JsonRpcClient objects is currently not supported.
JSONRPCCLIENT-COPY-ERROR | copying JsonRpcClient objects is currently not supported |
string Qore::Json::JsonRpcClient::getVersion | ( | ) |
Returns the JSON-RPC protocol version.
nothing Qore::Json::JsonRpcClient::setEventQueue | ( | ) |
clears the event queue for the JsonRpcClient object
nothing Qore::Json::JsonRpcClient::setEventQueue | ( | Queue | queue | ) |
sets the event queue for the JsonRpcClient object
queue | the Queue object to receive network events from the JsonRpcClient object |
nothing Qore::Json::JsonRpcClient::setVersion | ( | string | version | ) |
Sets the JSON-RPC protocol version.
version | the JSON-RPC protocol version |