Reputation: 247
all, I have a package full of Beans generated from xsd
with Jaxb
.
I want to use some of them into another Bean to marshal/unmarshal an XML like this:
<WrongDocument>
<test>test label</test>
<CBISDDReqLogMsg xmlns="urn:CBI:xsd:CBISDDReqLogMsg.00.01.00">
<GrpHdr>
....
</GrpHdr>
<PmtInf>
</PmtInf>
</CBISDDReqLogMsg>
</WrongDocument>
the root Bean is
@XmlRootElement(name="WrongDocument")
@XmlType(name = "", propOrder = {
"test",
"CBISDDReqLogMsg"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class WrongDocumentDTO implements Serializable {
private static final long serialVersionUID = 8545918230166653233L;
@XmlElement(required = true, type = String.class, nillable = true)
protected String test;
@XmlElement(required = true)
protected CBISDDReqLogMsg000100 CBISDDReqLogMsg;
....
}
and the CBISDDReqLogMsg000100
is
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CBISDDReqLogMsg.00.01.00", propOrder = {
"grpHdr",
"pmtInf"
})
public class CBISDDReqLogMsg000100
implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(name = "GrpHdr", required = true)
protected CBIGroupHeader2 grpHdr;
@XmlElement(name = "PmtInf", required = true)
protected List<PaymentInstructionInformation2> pmtInf;
....
}
For CBISDDReqLogMsg000100
namespace is defined with package-info
file.
This is the code for unmarshalling:
jc = JAXBContext.newInstance(WrongDocumentDTO.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
WrongDocumentDTO wrongDocumentDTO = unmarshaller.unmarshal(source, WrongDocumentDTO.class).getValue();
Unfortunately, inside my wrongDocumentDTO
i have test field populated with the right value, however CBISDDReqLogMsg
is null.
How can i resolve this issue?
thank you in advance
Upvotes: 0
Views: 725