Skip navigation
badgerduke2
Currently Being Moderated

Error #1063: Argument count mismatch on entities::Family(). Expected 2, got 0.

Dec 1, 2009 12:39 PM

Hello:

 

I'm trying to start a simple remoting app.  I'm getting the folowing error.  My value objects and remoting code are below.  Any help would be appreciated!

 

ArgumentError: Error #1063: Argument count mismatch on entities::Family(). Expected 2, got 0.
    at ObjectInput/readObject()
    at mx.messaging.messages::AbstractMessage/readExternal()[C:\autobuild\3. 2.0\frameworks\projects\rpc\src\mx\messaging\messages\AbstractMessage. as:377]
    at mx.messaging.messages::AsyncMessage/readExternal()[C:\autobuild\3.2.0 \frameworks\projects\rpc\src\mx\messaging\messages\AsyncMessage.as:146 ]
    at mx.messaging.messages::AcknowledgeMessage/readExternal()[C:\autobuild \3.2.0\frameworks\projects\rpc\src\mx\messaging\messages\AcknowledgeMe ssage.as:77]

 

 

Family class in Flex:

 

package entities
{
    [Bindable]
    [RemoteClass(alias="family.Family")]
    public class Family  {
       
        public function Family(father:Person, mother:Person) {
            this.father = father;
            this.mother = mother;
        }
       
        protected var father:Person;
        protected var mother:Person;

 

        public function getFather():Person {
            return father;
        }

 

        public function setFather(o:Person):void {
            father = o;
        }

 

        public function getMother():Person {
            return mother;
        }

 

        public function setMother(o:Person):void {
            mother = o;
        }
    }
}

 

 

Family object in Java

 

 

package family;

 

public class Family {
   
   
    private Person father = null;
    private Person mother = null;
   
    public Family(Person father, Person mother) {
        this.father = father;
        this.mother = mother;
    }
   
   
    public Person getFather() {
        return father;
    }
    public void setFather(Person father) {
        this.father = father;
    }
    public Person getMother() {
        return mother;
    }
    public void setMother(Person mother) {
        this.mother = mother;
    }

 

}

 

 

 


Person class in Flex:

 

package entities
{
    [Bindable]
    [RemoteClass(alias="family.Person")]
    public class Person {
       
        protected var givenName:String;
        protected var surname:String;
        protected var birthdate:String;
        protected var birthLocation:String;
        protected var deathdate:String;
        protected var deathLocation:String;

 

        public function getGivenName():String {
            return givenName;
        }

 

        public function setGivenName(o:String):void {
            givenName = o;
        }

 

        public function getSurname():String {
            return surname;
        }

 

        public function setSurname(o:String):void {
            surname = o;
        }

 

        public function getBirthdate():String {
            return birthdate;
        }

 

        public function setBirthdate(o:String):void {
            birthdate = o;
        }

 

        public function getBirthLocation():String {
            return birthLocation;
        }

 

        public function setBirthLocation(o:String):void {
            birthLocation = o;
        }

 

        public function getDeathdate():String {
            return deathdate;
        }

 

        public function setDeathdate(o:String):void {
            deathdate = o;
        }

 

        public function getDeathLocation():String {
            return deathLocation;
        }

 

        public function setDeathLocation(o:String):void {
            deathLocation = o;
        }

 

        public function Person()
        {
        }
    }

 

 

Person class in Java

 

 

package family;

 

public class Person {
   
    private String givenName = null;
    private String surname = null;
    private String birthdate = null;
    private String birthLocation = null;
    private String deathdate = null;
    private String deathLocation = null;
   
    public String getGivenName() {
        return givenName;
    }
    public void setGivenName(String givenName) {
        this.givenName = givenName;
    }
    public String getSurname() {
        return surname;
    }
    public void setSurname(String surname) {
        this.surname = surname;
    }
    public String getBirthdate() {
        return birthdate;
    }
    public void setBirthdate(String birthdate) {
        this.birthdate = birthdate;
    }
    public String getBirthLocation() {
        return birthLocation;
    }
    public void setBirthLocation(String birthLocation) {
        this.birthLocation = birthLocation;
    }
    public String getDeathdate() {
        return deathdate;
    }
    public void setDeathdate(String deathdate) {
        this.deathdate = deathdate;
    }
    public String getDeathLocation() {
        return deathLocation;
    }
    public void setDeathLocation(String deathLocation) {
        this.deathLocation = deathLocation;
    }
}

 

 

Remoting code:

 

...

    var family:Family;

 

      getRemoteFamily(function (familyOut:Family) : void {
         family = familyOut;
      } );

...

 

 

    public function getRemoteFamily(result:Function, fault:Function=null):void {   
        var token:AsyncToken = ro.getFamily();
        token.addResponder(new AsyncResponder(
       
                    function (data:Object, token:Object):void {
                        if (!data || !data.result) {
                            throw new Error("RO [getFamily] result object was null, or missing . . .");
                            return;
                        }                   
                        result(data.result as Family);
                    },
                   
                    function (info:Object, token:Object):void {
                        if (fault != null) fault(info);   
                    },
                   
                    token
        ));
    }

 
Replies
  • Currently Being Moderated
    May 10, 2011 4:58 AM   in reply to badgerduke2

    Hi,

    I was facing the same problem, then saw this http://forums.adobe.com/thread/471206. I think that all the value objects must have a constructor with default values. So initially if your constructor on the flex side was say:

     

    public function Parameter(name:String, value:String){

         this.name=name;

         this.value=value;

    }

     

    Then change it to :

    public function Parameter(name:String="", value:String=""){

         this.name=name;

         this.value=value;

    }

     

    I am not claiming this is how it should be done but doing this solved the problem for me.

    Also I think all the variables that u need to send to the server should be public otherwise they are not sent.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points