In CXF, why use any other binding than JAXB? (Attachments MTOM, Aegis, XMLBeans, ...)

I play with Apache CXF, in particular the various data bindings it supports: JAXB (default), MTOM, Aegis, and XMLBeans. Since they are all supported, I believe that each of them has its own merits. I figured it out:

  • Obviously, MTOM is preferable if large investments are involved.
  • JAXB is dependent on annotations, so it is less suitable when class modifications are limited.
  • Aegis does not have the wsdl2java tool, so it is less suitable for contract-first development, i.e. starts with WSDL and generates your Java code from this.
  • Aegis seems to provide a bit more control over the mapping between Java and XML classes through its declarative syntax in the Class.aegis.xml files. On the other hand, I could not develop any scenarios where JAXB did not perform the trick.

I found this question by comparing JAXB and XMLBeans, but it does not provide an exhaustive overview:

JAXB vs Apache XMLBeans

Besides these naive, a priori considerations, do you have any problems with blood and guts that will support the use of any binding other than JAXB? I ask from the point of view of CXF, but if other options come to mind (like Castor), please feel free to clarify.

+7
web-services jaxb xmlbeans cxf aegis
source share
2 answers

Starting from scratch to create the first WSDL web service, I definitely recommend sticking to JAXB 95% of the time (maybe even higher). This is definitely the best tested data binding in CXF and works pretty well.

If other data bindings are included, as a rule, for one of two cases:

1) Examples of using Java in Java, in which you have something already written in Java that you want to open as a web service, without any code changes. Aegis has strengths here as it is designed to handle a wider range of things than JAXB. However, if you can change the code, adding JAXB annotations is usually not that difficult. If you have mostly normal "beans", that doesn't really matter.

2) Existing applications that use a specific mapping. If you removed applications that expect XMLBeans beans (or SDO beans when using 2.3-SNAPSHOT CXF or JiBX beans if you follow the GSoC project), then using other data bindings can help by removing any necessary mappings from JAXB to these object models.

Hope this helps.

+3
source share

Remember that JAXB is a specification , so there are several implementations: Metro (Reference Implementation, MOXy (I’m the technology leader), etc.

JAXB can be used starting with Java classes or XML schemas. If you have classes that cannot be changed, individual JAXB applications offer extensions to handle this. See MOXy: external metadata:

JAXB was designed to work with MTOM attachments, see the marshaller / unmarshaller application.

MOXy has XPath-based mappings that provide complete control over the binding of an object to XML:

+3
source share

All Articles