pxd119 / as3-rpclib

Automatically exported from code.google.com/p/as3-rpclib
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Objects are not serialized #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the makeCall function 

makeCall("metaWeblog.newPost",[_blogid,_user,_password,{title:"dude",description
:"dude"},true]);

2. Pass in an object as one of the arguments 
3. Looking at the XML RPC message the object is null. Looking at
encodeObject() method in the XMLRPCSerializer class there is no check to
see if (tobject is Object). 

What is the expected output? What do you see instead?
I am not an xml rpc expert but I think it should be a struct. Instead I see
a null string:

    < param>
      < value>
        < string>null</string>
      < /value>
    < /param>

What version of the product are you using? On what operating system?
Downloaded the source from SVN. Win XP.

Please provide any additional information below.

Original issue reported on code.google.com by dorkiedo...@gmail.com on 23 Oct 2007 at 8:16

GoogleCodeExporter commented 8 years ago
The object should implement IXMLRPCStruct. I will re-visit this solution to see 
if
there is a cleaner way of handling object serialization

Original comment by akeemphi...@gmail.com on 23 Oct 2007 at 9:11

GoogleCodeExporter commented 8 years ago
Would you mind adding a document with a simple example of implementing 
IXMLRPCStruct?
I am hung up on this as well. It seems from flex that is the only way to pass an
associative array.

Original comment by sigil%ir...@gtempaccount.com on 23 Oct 2007 at 10:54

GoogleCodeExporter commented 8 years ago
In com.ak33m.rpc.xmlrpc.XMLRPCSerializer in encodeObject() I added the 
following line
after if (tobject is IXMLRPCStruct) condition:

            else if (tobject is IXMLRPCStruct)
            {
                txmllist =  encodeStruct(tobject.getPropertyData());
            }
            else if (tobject is Object) // added by judah oct 23
            {
                txmllist =  encodeStruct(tobject); 
            }

This seems to do work but I haven't tested it much. Akeem, does this look 
alright? 

Original comment by dorkiedo...@gmail.com on 24 Oct 2007 at 12:31

GoogleCodeExporter commented 8 years ago
I'd like to see an example implementing IXMLRPCStruct. I tried below and it is 
not
serialized. 

    import com.ak33m.rpc.xmlrpc.IXMLRPCStruct;

    [Bindable]
    public dynamic class BlogEntry implements IXMLRPCStruct {
        public function getPropertyData():* {
            return this;
        }
}

Original comment by dorkiedo...@gmail.com on 25 Oct 2007 at 12:42

GoogleCodeExporter commented 8 years ago
The encodeObject has a check for is String. Then we have the default condition 
that
converts to a string if the type does not match any condition we have checked 
for.
Maybe the default should be encode an object,

line 101:
            else
            {
                //txmllist = encodeString(tobject as String);
                txmllist = encodeStruct(tobject);
            }

or if string returns "null" then attempt to encode as a struct.

Original comment by dorkiedo...@gmail.com on 25 Oct 2007 at 9:31

GoogleCodeExporter commented 8 years ago
The spec fro xmlrpc requires that the default option be string. I have not been 
able
to test the solution outlined in comment 3 but is this no longer a viable 
solution?
To use the IXMLRPCStruct your data object should implement IXMLRPCStruct and the
getPropertyData should return an object containing the properties that you 
would like
serialized. The reason this was done is to facilitate serialization of strongly 
typed
data objects.

Original comment by akeemphi...@gmail.com on 26 Oct 2007 at 12:44

GoogleCodeExporter commented 8 years ago
the code in comment 3 works for objects, but i quickly found that i was using 
VO's.
as soon as i made my own class the condition did not match. 

could you post a simple example of implementing the IXMLRPCStruct? 

import com.ak33m.rpc.xmlrpc.IXMLRPCStruct;

[Bindable]
public dynamic class BlogEntry implements IXMLRPCStruct {

    public var myInt:uint = 0;
    public var myString:String = "";
    public var myArray:Array = [];

    public function getPropertyData():* {
        return ; // what goes here
    }
}

Original comment by dorkiedo...@gmail.com on 26 Oct 2007 at 1:15

GoogleCodeExporter commented 8 years ago
For your example that would be:

public dynamic class BlogEntry implements IXMLRPCStruct {

    public var myInt:uint = 0;
    public var myString:String = "";
    public var myArray:Array = [];

    public function getPropertyData():* {
        return {myInt:this.myInt,myString:this.myString,myArray:this.myArray};
    }
}

Original comment by akeemphi...@gmail.com on 26 Oct 2007 at 4:07

GoogleCodeExporter commented 8 years ago
Added dorkie's solution. 

Original comment by akeemphi...@gmail.com on 17 Apr 2008 at 3:48

GoogleCodeExporter commented 8 years ago
dorkie's solution isn't all the way there. 

i've created a patch which changes the for-loop in serialize() method and also
implements dorkie's object check

this seems to fully live up to the xmlrpc specs

Original comment by dhaarbrink@gmail.com on 4 Jun 2008 at 4:12

Attachments: