0

I am working integrating two system which exchange the data using the XML by service. Interfaces are given by other party and we us JAXB to generate Java class. I finished Integration and working fine.

Problem : We have complex XML structure, some elements and complex elements are optional. When we send back , obviously they are null, so Jaxb is not sending as empty tag. Other system need those Empty Tag(May be for audit)

I am using Java/JAXB to do my work.

Please help me to get quick generic solution that I can apply for all my services.

Kumar
  • 1,106
  • 4
  • 15
  • 33

1 Answers1

0

In the XSD we have an attribute called nillable, by specifying this JAXB considers as an element for Null values. Well, I can say "Element is no longer optional from the point of service as Jaxb will sure generate element". Even if you check the XSD in XMLSPY you can see that element is not optional. Basically Jaxb treats null value as a valid value.

Now there is another situation which wont resolve is Complex optional element. I mean if any one want to generate multi level optional elements with teh null values , JAXB makes parent as Nillable and child elements ignored. I am not sure how JAXB works here.

Kumar
  • 1,106
  • 4
  • 15
  • 33