I'm having troubles mapping a Collection of JAXB object within another JAXB object, anyone see the issue with my structure below? I get an empty formerUsers ArrayList using the following code:
String test="<SSO-Request><User-Id>3119043033121014002</User-Id><Former-User-Ids><User-Id>3119043033121014999</User-Id><User-Id>3119043033121014555</User-Id></Former-User-Ids></SSO-Request>";
SSORequest ssoRequest=null;
try{
JAXBContext jaxbContext = JAXBContext.newInstance(SSORequest.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
ssoRequest = (SSORequest) unmarshaller.unmarshal(new StringReader(test));
}
catch(Exception e){
e.printStackTrace();
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="SSO-Request")
public class SSORequest {
@XmlElement(name="User-Id")
String userId;
@XmlElementWrapper(name="Former-User-Ids")
List<FormerUser> formerUsers;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="Former-User-Ids")
public class FormerUser {
@XmlElement(name="User-Id")
String userId;
}