Menu

0.82 as2 -> Method.AddParameter() -> struct

2005-01-10
2013-04-09
  • Nobody/Anonymous

    hello,

    when adding a struct via Connection.addParameter() and initiating a Call (i am assuming that) the Method.Render() doesnt work as expected from the docs:

    quote--->
    MyStruct = new Array();
    MyStruct.push({name: "name", type: "string", value: "fred"});
    MyStruct.push({name: "job", type: "string", value: "coder"});
    MyStruct.push({name: "age", type: "int", value: 22});

    MyXMLRPC->AddParameter("struct",MyStruct);
    <---quote

    s.a. results into following xml for parameters:

    <params>
    <param>
      <value>
       <struct>
        <member>
         <name>2</name>
         <value>[object Object]</value>
        </member>
        <member>
         <name>1</name>
         <value>[object Object]</value>
        </member>
        <member>
         <name>0</name>
         <value>[object Object]</value>
        </member>
       </param>
    </params>
    </struct>

    i've taken a look at the Method.Render() and it looks (to me) like the code doesnt comply the doc-described behaviour at all (nested types?).

    my questions:
    1. am i right with the assumptions above?
    2. is the file i'm using (xmlrpcflash-v0.82.zip) the correct and latest release?

    hints and tips will be greatly appreciated.

    cheers<3
    -sh

     
    • Matt Shaw

      Matt Shaw - 2005-01-10

      .84 is the latest version

      The problem is that your passing in an Array not a Struct but are still specifying "struct". The Render() method does a "for in" loop on the Array which returns indexes of the array rather than what it expects, which is struct keys. Below is code that works with v 0.84.

      var x = new XMLRPC.Connection('http://blah');
      MyArray = new Array();
      MyArray.push({name: "name", type: "string", value: "fred"});
      MyArray.push({name: "job", type: "string", value: "coder"});
      MyArray.push({name: "age", type: "int", value: 22});

      x.AddParameter(MyArray,XMLRPC.types.ARRAY);
      x.Test();

       
    • Jos

      Jos - 2005-03-07

      I made a change to the render method to more easily support non-homogenious structs.

      The original code (from ~line 127 in method.as)

      <code>
      // add value node
      MemberNode.appendChild(this.createElement("value"));
      MemberNode.lastChild.appendChild(this.createTextNode(parameter.value[i]));
      </code>

      my change
      <code>
      MemberNode.appendChild(this.CreateParameterNode({type:parameter.value[i].type,value:parameter.value[i].value}));
      </code>

      This allows for passing in, basically, exactly what you have listed above. But you can still call your array a struct (XMLRPC.types.STRUCT) and it works.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.