I'm creating a REST service and I want to return a List of objects. So I got something like this:
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("items/")
@XmlElementWrapper(name = "items")
public List<AClass> getItems() {
List<AClass> list = db.getItems();
return list;
}
where db.getItems() returns a list of objects that are a type of subclasses of AClass. AClass is an abstract class. Objects have more fields added. But these additional fields are not generated in an XML. How can I have them in a result?
// Client
//ClientService
//JerseyClient
//POM.xml
Have you looked at XmlSeeAlso? That annotation will allow you to bind subclasses.