javaoxm

What is the best Java OXM library?


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.


Solution

  • 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.