Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » [bug] MOXy @XmlNullPolicy not working with enums
[bug] MOXy @XmlNullPolicy not working with enums [message #1838511] Fri, 26 February 2021 19:00
ender tercero is currently offline ender terceroFriend
Messages: 1
Registered: February 2021
Junior Member
I use MOXy to create XML responses for a SOAP web service and I need some tags to be printed even though the value is null. I'm using MOXy's XmlNullPolicy annotation for that purpose.

Here's an example:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "prop1",
    "prop2"
})
@XmlRootElement(name = "Response")
public class Response {
    @XmlElement(name = "Prop1")
    @XmlSchemaType(name = "string")
    @XmlNullPolicy(nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
    protected MyEnumType prop1;
    
    @XmlElement(name = "Prop2")
    @XmlNullPolicy(nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
    protected String prop2;
    
}


I'm expecing the following resulting XML:
<Response>
    <Prop1/>
    <Prop2/>
</Response>


But I'm getting:
<Response>
    <Prop2/>
</Response>


Prop1 is missing even though XmlNullPolicy annotation is correctly defined.

Any idea or solution?
Previous Topic:Metamodel generation issue for @NotNull and @Lob byte[]
Next Topic:EclipseLink 3.0 post-upgrade performance degradation
Goto Forum:
  


Current Time: Thu Mar 28 22:00:25 GMT 2024

Powered by FUDForum. Page generated in 0.03188 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top