Tech Stack: Java 1.6, JAXB, Spring 3, JAX-RS (RESTEasy), XSD
Hello,
I am using Spring with JAX-RS to create RestFul Webservice.
Everything is working fine except that the generated responses contain the setters info e.g.
{
...
"setName": true,
"setId": true,
"setAddress": true,
"setAge": true,
}
I don’t know what might be causing this?
How can I turn this off?
Adi
UPDATE 1:
The PersonRequest class is generated by the JAXB and contains all the javax.xml.bind.annotation.* annotations.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "personResponse " })
@XmlRootElement(name = "PersonResponse ")
public class PersonResponse {
@XmlElement(name = "Name", required = true)
protected String name;
@XmlElement(name = "Id", required = true)
protected String id;
// and the setters and getters
}
and the Resource looks like this:
@Component
@Path("/person")
public class PersonImpl implements Person {
@Override
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, "application/x-amf" })
@Path("v1")
public PersonResponse getPerson() {
....
....
}
}
** UPDATE 2 **
This happens only when Content-Type is json, in case of Content Type as ‘xml’, the setters are not returned. If that helps.
Problem was in the xjb file, for details look in the related question here.