Menu

Problems serializing an Object

Help
Anonymous
2012-08-08
2013-04-25
  • Anonymous

    Anonymous - 2012-08-08

    I am new to XMLRPC and I am working a XMLRPC Servlet hosted on Jetty.
    Right now I am having some problems serializing simple objects using the build in IntropectingSerializer.

    I have a simple class:

    public Person
    {
      String name;
      String address;
      int age;
      List<String> parents;

      //constructor
      public Person(String name, String, address, int age, List<String> parents); 

      //getter methods
      String getName(){return this.name;}
      String getAddress(){return this.address;}
      String getAge(){return this.age;}
      List<String> getParents(){return parents;}
    }

    in the client I have:

    List<String> parents = new ArrayList<String>()
    parents.add("mary");
    parents.add("jackson");
    Person test = new Person("alvin", "24 lorong", 15,  parents);

    XmlRpcStruct rs = (XmlRpcStruct)client.invoke("server.sendPerson", new Object {test});

    when invoking the rpc method, I get the following errors:
    Could not serialize property:
    at redstone.xmlrpc.serializers.IntrospectingSerializer.serialize
    at redstone.xmlrpc.XmlRpcSerializer.serialize
    at redstone.xmlrpc.XmlRpcClient.invoke
    at Main.main(Main.java 53)

    Correct me if I am wrong, shouldn't the introspectiveSerializer serialize the class into a xmlrpcStruct using the getter methods defined in the class. However I am getting errors with the serialize property. Any advice is greatly appreciated!

     
  • Greger Olsson

    Greger Olsson - 2012-08-08

    Could it be that your accessors (getters) are not public? I'll do a quick experiment myself here, but perhaps you could check on your end too by making them public so that they show up during introspection.

    BR,
    Greger.

     

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.