www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - XML RPC Client and Server - meet xmlrpc-d

reply "Pavel Kirienko" <pavel.kirienko gmail.com> writes:
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.
Sep 01 2013
next sibling parent reply "angel" <andrey.gelman gmail.com> writes:
Did you look at std.serialization (currently in the review queue)
? An RPC does need serialization.
Sep 01 2013
parent "Pavel Kirienko" <pavel.kirienko gmail.com> writes:
On Monday, 2 September 2013 at 05:53:22 UTC, angel wrote:
 Did you look at std.serialization (currently in the review 
 queue)
 ? An RPC does need serialization.
Yes I'm aware of std.serialization, but it does not seem to support XML-RPC data representation. So I decided to use std.xml, with plans to switch to std.xml2 when available.
Sep 02 2013
prev sibling next sibling parent reply "Flamaros" <flamaros.xavier gmail.com> writes:
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.
Sep 02 2013
next sibling parent reply "ilya-stromberg" <ilya-stromberg-2009 yandex.ru> writes:
On Monday, 2 September 2013 at 10:31:15 UTC, Flamaros wrote:
 We'll need RPC for our projects, we are interested.

 I hope you'll made pull requests for an integration to phobos.
+1 It's really useful project.
Sep 02 2013
parent reply "Pavel Kirienko" <pavel.kirienko gmail.com> writes:
On Monday, 2 September 2013 at 14:07:52 UTC, ilya-stromberg wrote:
 On Monday, 2 September 2013 at 10:31:15 UTC, Flamaros wrote:
 We'll need RPC for our projects, we are interested.

 I hope you'll made pull requests for an integration to phobos.
+1 It's really useful project.
Thanks! To be honest, the HTTP server shipped with this library is not so hot, it is just a stub which purpose is to fill the lacking of the default HTTP server in phobos. https://github.com/pavel-kirienko/xmlrpc-d/blob/master/src/http_server_bob.d I think there is no place for this particular piece of code in phobos. So, the question is: shall I make a pull request for xmlrpc-d with no HTTP server included? Is there anyone who have a solid HTTP server which is good enough for the standard library? We could cooperate.
Sep 02 2013
parent reply "ilya-stromberg" <ilya-stromberg-2009 yandex.ru> writes:
On Monday, 2 September 2013 at 15:12:24 UTC, Pavel Kirienko wrote:
 So, the question is: shall I make a pull request for xmlrpc-d 
 with no HTTP server included? Is there anyone who have a solid 
 HTTP server which is good enough for the standard library? We 
 could cooperate.
As I know, the Vibe.d is good: https://github.com/rejectedsoftware/vibe.d But I don't know if it will be useful for you.
Sep 02 2013
parent reply "Pavel Kirienko" <pavel.kirienko gmail.com> writes:
On Monday, 2 September 2013 at 15:37:16 UTC, ilya-stromberg wrote:
 On Monday, 2 September 2013 at 15:12:24 UTC, Pavel Kirienko 
 wrote:
 So, the question is: shall I make a pull request for xmlrpc-d 
 with no HTTP server included? Is there anyone who have a solid 
 HTTP server which is good enough for the standard library? We 
 could cooperate.
As I know, the Vibe.d is good: https://github.com/rejectedsoftware/vibe.d But I don't know if it will be useful for you.
I know vibe.d, but it does not seem to be going into phobos, does it?
 I should warn - it won't be easy and is likely to require lot 
 of work from contributor. Recent trend in Phobos contribution 
 is to require good integration with existing modules and 
 approaches - you can have a look at `std.serialization` threads 
 to see what Jacob is going to go through to get to voting.
Yeah it is not so easy I know, and I'm not sure I can make time for that right now. However, if someone wants to volunteer I'd glad to help.
Sep 02 2013
next sibling parent "ilya-stromberg" <ilya-stromberg-2009 yandex.ru> writes:
On Monday, 2 September 2013 at 15:54:12 UTC, Pavel Kirienko wrote:
 I know vibe.d, but it does not seem to be going into phobos, 
 does it?
I don't know, you should contact Sönke Ludwig to find out it. As I can see, there are a lot of code that could be useful for Phobos.
Sep 02 2013
prev sibling parent reply "Flamaros" <flamaros.xavier gmail.com> writes:
On Monday, 2 September 2013 at 15:54:12 UTC, Pavel Kirienko wrote:
 On Monday, 2 September 2013 at 15:37:16 UTC, ilya-stromberg 
 wrote:
 On Monday, 2 September 2013 at 15:12:24 UTC, Pavel Kirienko 
 wrote:
 So, the question is: shall I make a pull request for xmlrpc-d 
 with no HTTP server included? Is there anyone who have a 
 solid HTTP server which is good enough for the standard 
 library? We could cooperate.
As I know, the Vibe.d is good: https://github.com/rejectedsoftware/vibe.d But I don't know if it will be useful for you.
I know vibe.d, but it does not seem to be going into phobos, does it?
 I should warn - it won't be easy and is likely to require lot 
 of work from contributor. Recent trend in Phobos contribution 
 is to require good integration with existing modules and 
 approaches - you can have a look at `std.serialization` 
 threads to see what Jacob is going to go through to get to 
 voting.
Yeah it is not so easy I know, and I'm not sure I can make time for that right now. However, if someone wants to volunteer I'd glad to help.
I don't think a real server is needed here. A simple listen on a port is sufficient.
Sep 02 2013
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
02-Sep-2013 20:41, Flamaros пишет:
 On Monday, 2 September 2013 at 15:54:12 UTC, Pavel Kirienko wrote:
 I don't think a real server is needed here. A simple listen on a port is
 sufficient.
Well I don't expect that to pass review :) -- Dmitry Olshansky
Sep 02 2013
prev sibling parent "Dicebot" <public dicebot.lv> writes:
On Monday, 2 September 2013 at 10:31:15 UTC, Flamaros wrote:
 I hope you'll made pull requests for an integration to phobos.
I should warn - it won't be easy and is likely to require lot of work from contributor. Recent trend in Phobos contribution is to require good integration with existing modules and approaches - you can have a look at `std.serialization` threads to see what Jacob is going to go through to get to voting. One may argue if it is too demanding but I personally like high quality and consistency levels defined by standard library.
Sep 02 2013
prev sibling parent reply "Pavel Kirienko" <pavel.kirienko gmail.com> writes:
Guys, I decided to stay away from phobos integration at least 
until it has some HTTP server out of the box.
Anyway this decision does not make xmlrpc-d less usable. :)
Sep 03 2013
parent "ilya-stromberg" <ilya-stromberg-2009 yandex.ru> writes:
On Tuesday, 3 September 2013 at 10:28:56 UTC, Pavel Kirienko 
wrote:
 Guys, I decided to stay away from phobos integration at least 
 until it has some HTTP server out of the box.
 Anyway this decision does not make xmlrpc-d less usable. :)
You can try to integrate in Phobos only xmlrpc-d client. It can be useful for integration whith 3rd-party XML RPC servises.
Sep 03 2013