What is the best Java OXM library?
Asked Answered
S

4

6

Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution.

The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations?

One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.

Selfservice answered 5/1, 2009 at 16:7 Comment(0)
V
6

If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes.

I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead:

java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL

This will generate similar stubs to JAXB.

If you don't have a WSDL or XSD, you can always generate one.

Valency answered 5/1, 2009 at 16:42 Comment(0)
N
10

JAXB is the best choice:

EclipseLink JAXB (MOXy) is the best implementation:

MOXy is a JAXB implementation with Extensions

MOXy has an external configuration file (based on JAXB annotations with extensions):

Has XPath based mapping, for deep mapping:

Designed to handle ORM mapped objects, including support for bidirectional relationships:

Nannette answered 8/7, 2010 at 14:15 Comment(0)
V
6

If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes.

I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead:

java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL

This will generate similar stubs to JAXB.

If you don't have a WSDL or XSD, you can always generate one.

Valency answered 5/1, 2009 at 16:42 Comment(0)
V
3

There's XStream. I seem to remember I used that ages ago, and it was fine. Can't say I have enough experience to recommend it for or against, but it's worth checking out just as an alternative.

Villatoro answered 5/1, 2009 at 16:12 Comment(2)
XStream is awesome for Java object -> XML. It's not ideal for the reverse. Assuming you have a WSDL or XSD, JAXB is better at the latter.Valency
In my experience, XStream is always very tempting to start with, since it's so easy, but then it ends up being so buggy that I always abandon it for JAXB eventually.Janitajanith
B
3

JIBX - known for performance

JAXB2 - Ease of use

Castor - Ease of use

others - XMLBean, Xstream

Belabor answered 19/11, 2009 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.