Qore YamlRpcClient Module Reference
1.1
|
This module implements client-side support for a proprietary RPC-based protocol using YAML for serialization/deserialization of message data.
The following classes are provided by this module:
YAML-RPC is an HTTP-based RPC protocol; it is not a standard protocol, however it is based on JSON-RPC 1.1 and similar in approach to XML-RPC.
YAML-RPC has some technical advantages over JSON-RPC and XML-RPC when developing in Qore:
The major drawback is that it is a proprietary protocol, which is why Qore will continue to support XML-RPC and JSON-RPC alongside YAML-RPC.
The information below provides technical information about how this proprietary YAML-RPC protocol is implemented; details which are not normally visible when using the YamlRpcClient class.
Request messages are sent as a YAML-encoded request string as the message body of an HTTP POST message. The "Content-Type"
header should be set to MimeTypeYamlRpc
(from Mime.qm), otherwise there are no special restrictions on the message headers.
Request and response message bodies must always be encoded with UTF-8 encoding.
YAML-RPC request strings are constructed as a simple YAML map with the following keys:
method:
the string method name to callparams:
any value giving the arguments for the method; if the method takes more than one argument, then the "params"
key will hold a list of the arguments. The YamlRpcClient class will always package a single argument in a list.Note that this YAML-RPC implementation uses the Qore YAML module to encode and decode YAML strings; this ensures maximum data fidelity when serializaing data; note that the Qore yaml module uses the proprietary !duration
tag for durations, otherwise all other tags are standard YAML tags. For details on how Qore data is serialized and deserialized by the yaml module, please see the yaml module documentation.
The following is an example of a simple request message with headers:
Normal (non-error) responses are returned as a YAML map as well with the following key:
result:
a map where the only key is the method name and the value is the value returned by the method.For example, for the message above, the response message would be:
Error responses are also returned as a YAML map with a single key, error
, which is itself a map with the following keys:
name:
always "YAMLRPCError"
code:
an integer error codemessage:
an error messageerror:
an optional error value of any formatThe following is an example error response message: