module XmlRpc:sig
..end
XmlRpc Light.
XmlRpc Light is a minimal XmlRpc library based on Xml Light and Ocamlnet.
It provides a type for values, a client class with a simple calling interface, and low-level tools that can be used to implement a server.
(c) 2007-2009 Dave Benjamin
val version : string
Version of XmlRpc-Light as a string.
Example:
let rpc = new XmlRpc.client "http://localhost:8000" in
let result = rpc#call "echo" [`String "hello!"] in
print_endline (XmlRpc.dump result)
exception Error of (int * string)
Raised for all errors including XmlRpc faults (code, string).
typevalue =
[ `Array of value list
| `Binary of string
| `Boolean of bool
| `DateTime of XmlRpcDateTime.t
| `Double of float
| `Int of int
| `Int32 of int32
| `Nil
| `String of string
| `Struct of (string * value) list ]
Polymorphic variant type for XmlRpc values:
`Array
: An ordered list of values`Binary
: A string containing binary data`Boolean
: A boolean`DateTime
: A date/time value`Double
: A floating-point value`Int
: An integer`Int32
: A 32-bit integer`Nil
: A null value`String
: A string`Struct
: An association list of (name, value) pairsNote that base64-encoding of `Binary
values is done automatically.
You do not need to do the encoding yourself.
class client :?debug:bool -> ?headers:(string * string) list -> ?insecure_ssl:bool -> ?timeout:float -> ?useragent:string -> string ->
object
..end
Class for XmlRpc clients.
class multicall :client ->
object
..end
Convenience class for system.multicall
calls.
val dump : value -> string
Converts an XmlRpc value to a human-readable string.
type
message =
| |
MethodCall of |
| |
MethodResponse of |
| |
Fault of |
Type for XmlRpc messages.
val message_of_xml_element : ?base64_decoder:(string -> string) ->
?datetime_decoder:(string -> XmlRpcDateTime.t) -> Xml.xml -> message
Converts an Xml Light element to an XmlRpc message.
val xml_element_of_message : ?base64_encoder:(string -> string) ->
?datetime_encoder:(XmlRpcDateTime.t -> string) -> message -> Xml.xml
Converts an XmlRpc message to an Xml Light element.
val value_of_xml_element : ?base64_decoder:(string -> string) ->
?datetime_decoder:(string -> XmlRpcDateTime.t) -> Xml.xml -> value
Converts an Xml Light element to an XmlRpc value.
val xml_element_of_value : ?base64_encoder:(string -> string) ->
?datetime_encoder:(XmlRpcDateTime.t -> string) -> value -> Xml.xml
Converts an XmlRpc value to an Xml Light element.
val serve : ?base64_encoder:(string -> string) ->
?base64_decoder:(string -> string) ->
?datetime_encoder:(XmlRpcDateTime.t -> string) ->
?datetime_decoder:(string -> XmlRpcDateTime.t) ->
?error_handler:(exn -> message) ->
(string -> value list -> value) -> string -> string
Creates a function from string (Xml representing a MethodCall
) to
string (Xml representing a MethodResult
or Fault
) given a function
of the form: (name
-> params
-> result
), where name
is the
name of the method, params
is a list of parameter values, and
result
is the result value.
This function can be used to build many different kinds of XmlRpc servers since it makes no assumptions about the network library or other communications method used.
If an exception other than XmlRpc.Error
occurs, the exception is
passed to error_handler
. If error_handler
returns a message,
the message will be used as the result. If an XmlRpc.Error
is
raised by either the main function or error_handler
, it will be
converted to an XmlRpc Fault
. Any other exception raised by
error_handler
is allowed to escape.
For a full-featured, easy-to-use, network-capable server implementation,
see the XmlRpcServer
module.
val serve_message : ?error_handler:(exn -> message) ->
(string -> value list -> value) ->
message -> message
Performs the same function as serve
, but operates on typed messages
instead of strings.
val default_error_handler : exn -> message
The default error handler for serve
.
This error handler catches all exceptions and converts them into
faults by wrapping them in XmlRpc.Error
.
val quiet_error_handler : exn -> message
A "quiet" error handler for serve
.
This error handler simply re-raises the exception. Use this if you want exceptions to remain unhandled so that they will escape to the error log. The client will receive a generic "transport error", which is more secure since it does not reveal any information about the specific exception that occurred.