I'm developing a JERSEY RESTFUL web service which has a function that accept an object parameter. It is called "Synchronize" and looks like this:
@XmlRootElement
public class Synchronize {
private List<PHQ9> phq9OutOfSync;
private List<ExtraQuestions> extraQuestionsOutOfSync;
private List<Suicide> suicideOutOfSync;
private List<Brugha> brughaOutOfSync;
private int hola;
public Synchronize() {
phq9OutOfSync = new ArrayList<PHQ9>();
extraQuestionsOutOfSync = new ArrayList<ExtraQuestions>();
suicideOutOfSync = new ArrayList<Suicide>();
brughaOutOfSync = new ArrayList<Brugha>();
}
}
The problem is I am not able to send a xml with the serialization of this class to the web service. I send an xml with all the attributes but it doesn't deserialize it well... I don't know if it is because the Lists that are doing some problems or so. I even tried sending only the int attribute like:
<synchronize><hola>1</hola></synchronize>
and doesn't work too... What is going on?
Any hints?
EDIT: I'm seeing that I don't know how I can refer to an attribute that is in a class. I tried making a web service that accepts a list with phq9 objects, and it works great, but if I put that list in other class, then it doesn't know how to deserialize. Why could it be?
EDIT2:
@XmlRootElement
public class PHQ9 {
@XmlElement
private int id;
@XmlElement
private int patientId;
@XmlElement
private int answer1;
@XmlElement
private int answer2;
@XmlElement
private int answer3;
@XmlElement
private int answer4;
@XmlElement
private int answer5;
@XmlElement
private int answer6;
@XmlElement
private int answer7;
@XmlElement
private int answer8;
@XmlElement
private int answer9;
@XmlElement
private int answer10;
@XmlElement
private int total;
@XmlElement
private int week;
@XmlElement
private String phq9Date;
@XmlElement
private String timeExported;
@XmlElement
private String dateExported;
@XmlElement
private int exported;
public PHQ9() {
phq9Date = timeExported = dateExported = "";
}
}