The XML file is following:
<AuthnRequest xmlns="A" ID="B">
<Issuer xmlns="A">SOMETHING</Issuer>
<NameIDPolicy Format="B" AllowCreate="true"/>
</AuthnRequest>
So how to transform this file with many attributes to a Javabean?
I tired this like this but didn't work
@XmlRootElement(name="AuthnRequest")
@XmlAccessorType(XmlAccessType.FIELD)
public class UserAuthn {
@XmlAttribute
private String xmlns;
@XmlAttribute
private String ID;
@XmlAttribute
private String Version;
@XmlAttribute
private String IssueInstant;
@XmlElement
private List<Issuer> Issuers;
@XmlElement
private List<NameIDPolicy> NameIDPolicys;
// Getters and Setters
}
Class Issuer
private String xmlns;
@XmlAttribute
public String getXmlns() {
return xmlns;
}
public void setXmlns(String xmlns) {
this.xmlns = xmlns;
}
Class NameIDPolicy is the same :
private String Format;
private String AllowCreate;
@XmlAttribute(name="AllowCreate")
public String getFormat() {
return Format;
}
public void setFormat(String format) {
Format = format;
}
@XmlAttribute(name="Format")
public String getAllowCreate() {
return AllowCreate;
}
public void setAllowCreate(String allowCreate) {
AllowCreate = allowCreate;
}
And the error is
threw exception [Request processing failed; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"A", local:"AuthnRequest"). Expected elements are <{}AuthnRequest>] with root cause
No comments:
Post a Comment