I have a series of xml messages, all with their own schemas and namespaces. The messages are currently marshalled using JAXB (we still live in a Java 1.4 environment) and we have a large amount of legacy code using this JAXB code so any solution needs to be minimally intrusive.
My problem is that while each of the messages has a set of common header tags the namespace covers the entire message and therefore makes the header for each message unique as well. As a result the "common" header sections are loaded into the namespace bound versions using a common class that is implemented using very ugly proxy classes and dynamic reflection code. This common class has been identified as the source of some performance issues.
Ideally I want to implement a replacement using the following:
- Use Maven2 to replace current manual jaxb build process.
- Generate once-off JAXB classes for "common" headers to be reused in each message.
- Convert current dynamic/proxy classes to use the above concrete header classes.
- Generate JAXB classes for unqiue section of each message.
Unfortunately, I don't have control of the message structure otherwise I would look at creating a seperate "header" namespace. I thought of running an XSLT transform to "rename" the header namespace after marshalling and prior to unmarshalling but I would prefer to avoid the extra load if possible, even if it means a more complex build.
Is what I want to do feasible or have I missed something fundamental? Is there any hints as to how to implement? Plugin versions etc?
Addendum 1: Binding using javaType would do the job but it appears that doesn't work for complex types.
Addendum 2: Binding using class almost does it as well but I would want it to specify a specific class and package so I could ignore the generated duplicates.