The non default constructor is never called in my Person class when I attempt to consume rest service which takes Person as a parameter.
Here is my 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 is my 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 is the body of my rest call:
{
"person": { "name":"some name"}
}
The name of the person object passed createPerson is always blank (or whatever I specify in the default constructor)
Any clue why??? Also the method does return successfully so it is responding right just not accepting the object properly