Menu

BUG: struct/array mixed up

Help
Anonymous
2003-06-24
2003-06-24
  • Anonymous

    Anonymous - 2003-06-24

    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

     
    • Chris Morley

      Chris Morley - 2003-06-24

      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;

       

Log in to post a comment.