+

Search Tips   |   Advanced Search

Use JAXB for XML data binding


Overview

Java Architecture for XML Binding (JAXB) is an XML-to-Java binding technology that maps Java classes with XML schemas using...

An XML schema defines the data elements and structure of an XML document.

JAXB is the default data binding technology used by the JAX-WS tooling.

WAS v9 supports the JAXB 2.2 specification. JAX-WS 2.2 requires JAXB 2.2.

The xjc schema compiler tool enables us to start with an XML schema definition (XSD) and then create a set of JavaBeans that map to the elements and types defined in the XSD schema.

We can also start with a set of JavaBeans and use the schemagen schema generator tool to create the XML schema.

In addition to using the tools from the command-line, we can invoke these JAXB tools from within the Ant build environments using the task...

...and the task...

To use, add com.ibm.jaxb.tools.jar and the com.ibm.jaxws.tools.jar files to the classpath.

The JAXB runtime API enables marshaling of JAXB objects to XML files and unmarshaling the XML document back to JAXB class instances. The JAXB binding package, javax.xml.bind, defines the abstract classes and interfaces used directly with content classes. In addition the package defines the marshal and unmarshal APIs.

We can optionally use JAXB binding customizations to override the default generated type mappings. We can customize JAXB bindings using inline annotations in the source schema, or using an external bindings customization file to pass our customizations to the JAXB binding compiler, xjc, to control the Java type mappings. Alternatively, we can add Java annotations to existing Java classes to pass to the schema generator, schemagen, to control the schema or XML type mappings. See the JAXB specification for information regarding binding customization options and Java annotations.

  1. Generate an XML schema from a Java class
  2. Generate Java classes from an XML schema
  3. Marshal and unmarshal XML documents


Subtopics

  1. Use JAXB schemagen tooling to generate an XML schema file from a Java class
  2. Use JAXB xjc tooling to generate JAXB classes from an XML schema file
  3. Use the JAXB runtime to marshal and unmarshal XML documents
  4. xjc command for JAXB applications
  5. schemagen command for JAXB applications
  6. Use JAXB schemagen tooling to generate an XML schema file from a Java class
  7. Use JAXB xjc tooling to generate JAXB classes from an XML schema file
  8. Use the JAXB runtime to marshal and unmarshal XML documents
  9. xjc command for JAXB applications
  10. schemagen command for JAXB applications


Related:

  • JAXB
  • Development and assembly tools
  • Web services specifications and APIs
  • JAXB 2.2 Reference implementation