java - Jersey post consume always calls objects default constructor -
the non default constructor never called in person class when attempt consume rest service takes person parameter.
here person class:
@xmlrootelement(name = "person") public class person { protected string name; public person(string name) { this.name=name; } // default constructor public person(){this.name="";} @xmlelement(required=true, name="name") public string getname() { return name; } public void setname(string name) { this.name = name; }; }
here web method:
@path("person/") public class postresource { @path("create") @post @produces("text/plain") @consumes("application/json") public string createperson(person person) { return person.getname(); } }
here body of rest call:
{ "person": { "name":"some name"} }
the name of person object passed createperson blank (or whatever specify in default constructor)
any clue why??? method return responding right not accepting object properly
Comments
Post a Comment