module XmlRpc:sig
..end
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
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)
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 ]
`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) pairs`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 multicall :client ->
object
..end
system.multicall
calls.
val dump : value -> string
type
message =
| |
MethodCall of |
| |
MethodResponse of |
| |
Fault of |
val message_of_xml_element : ?base64_decoder:(string -> string) ->
?datetime_decoder:(string -> XmlRpcDateTime.t) -> Xml.xml -> message
val xml_element_of_message : ?base64_encoder:(string -> string) ->
?datetime_encoder:(XmlRpcDateTime.t -> string) -> message -> Xml.xml
val value_of_xml_element : ?base64_decoder:(string -> string) ->
?datetime_decoder:(string -> XmlRpcDateTime.t) -> Xml.xml -> value
val xml_element_of_value : ?base64_encoder:(string -> string) ->
?datetime_encoder:(XmlRpcDateTime.t -> string) -> value -> Xml.xml
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
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
serve
, but operates on typed messages
instead of strings.val default_error_handler : exn -> message
serve
.
This error handler catches all exceptions and converts them into
faults by wrapping them in XmlRpc.Error
.
val quiet_error_handler : exn -> message
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.