I have autogenerated java classes from xsd using xsd2java
. I cannot modify neither xsd nor the java classes.
Problem: in one class an element of List<JAXBElement>
is generated.
If I now add any JAXBElement
, the jackson
xml marshaller won't show the proper xml element, but the properties of the JAXBElement
serialized. Like declaredType
, scope
, etc. See below.
@XmlRootElement(name = "bookingRequest")
public class AutogeneratedReq {
private List<JAXBElement<?>> someElements;
}
Usage:
AutogeneratedReq req = new AutogeneratedReq();
JAXBElement<?> person = new ObjectFactory().createPerson();
req.getSomeElements().add(person);
Result:
<someElements>
<JAXBElement>
<name>person</name>
<declaredType>net.some.company.Person</declaredType>
<scope>net.some.company</scope><value someattribues="test"/>
<nil>false</nil>
<globalScope>false</globalScope>
<typeSubstituted>false</typeSubstituted>
</JAXBElement>
</someElements>
Question: how can I tell jackson
or spring-mvc
to generate proper xml, and not JAXBElement
serialization explicit?