I am a little bit confused about the HelloClient/Server example within the 0.7 distribution. Why are the attributes of the 'Sum' method not encoded using an <array> construct?
I enabled debugs inside the Client and saw that data is encoded using an ordinary <param> sequence.
I found no way to transmit a RpcValue within an array construct to the XML-Rpc Server. So whenever I talk with an perl RPC::XML server which expexts an array as input I get an type error from the server.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The arguments to an XmlRpc++ method are passed in an array because that is easy and flexible. An advantage of languages like java with introspection is that they can do run time type checking of the arguments (in fact, they have to).
To use XmlRpc++, on the client side you stuff all your arguments into an array, and on the server side you have to extract the arguments from an array. It does make variable numbers and types of arguments simple, but it means delegating type-checking to the actual server methods. The Sum method takes advantage of that approach and sums up all the arguments, rather than having the client construct an array as the only argument.
Anyway, to answer the question "how do I pass an array argument to an XMLRPC method?", you just stuff the array in to the argument array, like any other argument. Suppose the Sum method was defined to take a single argument, an array of doubles, then it would be called like this:
XmlRpcValue arrayArg;
arrayArg[0] = 33.33;
arrayArg[1] = 112.57;
arrayArg[2] = 76.1;
XmlRpcValue args;
args[0] = arrayArg; // The first arg is an array of numbers
I am a little bit confused about the HelloClient/Server example within the 0.7 distribution. Why are the attributes of the 'Sum' method not encoded using an <array> construct?
I enabled debugs inside the Client and saw that data is encoded using an ordinary <param> sequence.
I found no way to transmit a RpcValue within an array construct to the XML-Rpc Server. So whenever I talk with an perl RPC::XML server which expexts an array as input I get an type error from the server.
The arguments to an XmlRpc++ method are passed in an array because that is easy and flexible. An advantage of languages like java with introspection is that they can do run time type checking of the arguments (in fact, they have to).
To use XmlRpc++, on the client side you stuff all your arguments into an array, and on the server side you have to extract the arguments from an array. It does make variable numbers and types of arguments simple, but it means delegating type-checking to the actual server methods. The Sum method takes advantage of that approach and sums up all the arguments, rather than having the client construct an array as the only argument.
Anyway, to answer the question "how do I pass an array argument to an XMLRPC method?", you just stuff the array in to the argument array, like any other argument. Suppose the Sum method was defined to take a single argument, an array of doubles, then it would be called like this:
XmlRpcValue arrayArg;
arrayArg[0] = 33.33;
arrayArg[1] = 112.57;
arrayArg[2] = 76.1;
XmlRpcValue args;
args[0] = arrayArg; // The first arg is an array of numbers
c.execute("SumTakingArrayOfNumbers", args, result);