It is not a bug, but I agree that it is confusing.
The arguments to RPCs are passed as an array-valued XmlRpcValue, which is what you are seeing on the server side (the first argument in the array is your struct).
On the client side, if a non-array-valued arg is passed, the library wraps it in an array. This is just a short cut for specifying the arguments array explicitly:
XmlRpcValue firstArg;
firstArg["ip"] = "127.0.0.1";
firstArg["port"] = 8000;
XmlRpcValue argsArray; // Pass this as the argument array
argsArray[0] = firstArg;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On the client side:
XmlRpcValue args;
args["ip"] = "127.0.0.1";
args["port"] = "8000";
On the server side I have to write this:
string ip = params[0]["ip"];
string port = params[0]["port"];
It seems that a single struct is processed like an array on the server side even if its type is a struct
in the client side.
Should not be the following on the server side, too:
string ip = params["ip"];
string port = params["port"];
is it a bug?
thanks
It is not a bug, but I agree that it is confusing.
The arguments to RPCs are passed as an array-valued XmlRpcValue, which is what you are seeing on the server side (the first argument in the array is your struct).
On the client side, if a non-array-valued arg is passed, the library wraps it in an array. This is just a short cut for specifying the arguments array explicitly:
XmlRpcValue firstArg;
firstArg["ip"] = "127.0.0.1";
firstArg["port"] = 8000;
XmlRpcValue argsArray; // Pass this as the argument array
argsArray[0] = firstArg;