On Sunday, 1 September 2013 at 19:50:47 UTC, Pavel Kirienko wrote:
Hi everyone,
I am working on some D-based project that needs to call and
serve XML-RPC procedures with multiple output parameters. Quick
lookaround revealed that:
1. There are no XML-RPC servers implemented in D, or wrapped in
D;
2. There are some simple XML-RPC clients, but no one supports
methods with multiple output parameters.
So I decided to write ultimate XML-RPC library that could
follow XML-RPC standard as close as ... well, as I could manage
it. :)
Grab your copy here: https://github.com/pavel-kirienko/xmlrpc-d
D's compile-time introspection is utterly amazing, it enables
such features as automatic conversion of a value which type is
not known at compile-time to something predefined. This makes
possible to define XML-RPC methods in the simplest way possible
(as regular functions), all the boring job of turning the
function parameters into XML-RPC types and vice versa is
carried out by compiler with the help of the Variant type:
----------
real multiply(real a, real b) { return a * b; }
xmlrpcServer.addMethod!multiply();
----------
Which also makes possble such weird things like that:
----------
// multiply() expects two arguments of type 'real' and returns
'real',
// but we call it with strings:
string ret = client.call!("multiply", string)("6", "9");
----------
Take a look into the 'example' directory on the Github page to
see more examples.
It is worth to mention that this is my first project in D - I
was concurrently studying "The D Programming Language" by
Andrei Alexandrescu (great book Andrei!), thus the code may
need some review.
Good luck with your projects,
Pavel.
We'll need RPC for our projects, we are interested.
I hope you'll made pull requests for an integration to phobos.
Good luck.