Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] ANN: XmlRpc-Light 0.5

1 view
Skip to first unread message

Dave Benjamin

unread,
Sep 15, 2007, 6:04:13 PM9/15/07
to caml...@yquem.inria.fr
I'm happy to announce the release of version 0.5 of XmlRpc-Light.
XmlRpc-Light is an XmlRpc library written in OCaml. It requires
Xml-Light and Ocamlnet 2.

http://code.google.com/p/xmlrpc-light/

New in version 0.5

* client: configurable socket timeouts
* client: basic authentication
* client: custom HTTP headers
* client: SSL support (requires command-line "curl" program)
* client: multicall class with optional lazy call behavior
* client: better interoperability with Apache XMLRPC
* client: code generation tool based on introspection functions
* server: methodHelp and methodSignature introspection functions
* server: shallow type checking of method signatures
* server: multiple signatures per method (overloading)
* both: proper text/xml Content-Type header and xml preamble
* both: 32-bit integer support

This version features a convenience class for "multicall", a de-facto
standard protocol for packaging multiple method calls together into a
single request. It uses OCaml's lazy type to keep the interface very
similar to regular method calls. Use of the lazy behavior is optional.

Instances take an XmlRpc.client as an argument:

# let mc = new XmlRpc.multicall client;;
val mc : XmlRpc.multicall = <obj>

The "call" method works like client#call, but it returns a lazy value:

# let a = mc#call "demo.addTwoNumbers" [`Int 3; `Int 4];;
val a : XmlRpc.value Lazy.t = <lazy>
# let b = mc#call "demo.addTwoNumbers" [`Int 42; `String "oh
noes!"];;
val b : XmlRpc.value Lazy.t = <lazy>
# let c = mc#call "demo.addTwoNumbers" [`Double 3.0; `Double 4.0];;
val c : XmlRpc.value Lazy.t = <lazy>

At this point, the call has not been executed yet:

# mc#executed;;
- : bool = false

As soon as one of the return values is forced, the call is executed:

# Lazy.force a;;
-- : XmlRpc.value = `Int 7
# mc#executed;;
- : bool = true

Once a call has been executed, this instance cannot be used to make any
further calls; instead, a new multicall instance must be created:

# mc#call "demo.addTwoNumbers" [`Int 2; `Int 2];;
Exception: Failure "multicall#call: already executed".

If an XmlRpc fault occurred, the exception will be thrown when the lazy
value is forced: # Lazy.force b;; Exception: XmlRpc.Error (-32602,
"server error. invalid method parameters"). ]} This will not prevent
further methods from executing successfully:

# Lazy.force c;;
- : XmlRpc.value = `Double 7.

It is possible for a multicall to be executed but not completed, for
example if a transport occurs. Aside from catching the exception, the
completed property indicates if the call actually went through or not:

# mc#completed;;
- : bool = true

It is not necessary to use lazy values. Instead, the call can be
executed explicitly, and the results can be retrieved by number:

# let mc = new XmlRpc.multicall client;;
val mc : XmlRpc.multicall = <obj>
# ignore (mc#call "demo.addTwoNumbers" [`Int 2; `Int 2]);;
-- : unit = ()
# ignore (mc#call "demo.addTwoNumbers" [`Int 3; `Int 3]);;
-- : unit = ()
# mc#result 1;;
-- : XmlRpc.value = `Int 6

This release also includes a fix to the WordPress example code, thanks
to Janne Hellsten. It has been tested with Ocamlnet 2.2.7 and 2.2.8,
though the use of 2.2.8 or newer is recommended for correct behavior of
the Netplex server.

Best wishes,
Dave

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

0 new messages