cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend/ replace generated classes from JAXB

Former Member
0 Kudos

Hello Experts,

In our application (Which uses Java Webdynpro as the UI and RFC’s for the backend access- an R/3 System), there is a need to construct an XML file (from the data entered by the user) which will be later accepted by the backend system. Now to avoid manual creation of the XML document, what we did is that we created an XSD file based on the back end structure (This XSD contains definition for all the possible fields and structures in the back end).

Then we used the JAXB implementation to automatically create Java Objects from the XSD file. We populate this JAXB generated Java objects and then use the Serialization framework to serialize them into an XML file.

This all works well, provided that the structure of the back end system does not change, but unfortunately it can, customer can add additional attributes to the existing structures (They do not create new structures, just add new attributes to it so I do not need to create new Java Object classes at runtime, I need only to add attributes to them). If they do so, the XSD and corresponding Java Objects (which are shipped as part of the source code) do not remain valid anymore as the automatically generated Objects (which correspond to the structures in the back end) would not have the definition of the newly added attributes.

Can anyone please suggest how to overcome this limitation with JAXB.

The needed functionality is that somehow I should be able to add fields (corresponding to the customer added attributes) to the automatically created Java objects and thus pass the data in the additional attribute to the backend. (Please note that at runtime using an RFC, I can find out the current structure of the backend but the structure at the Webdynpro end (set of Java objects generated from the JAXB) is static and is a part of the code).

Any comments/suggestions could be of great help.

Thanks

Amit Kapoor

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If the BASE class is not final, did you try to extend those class and create a new class with the new fields and pass it own?

regards

Vivek Nidhi.