# Modular Databinding

## Introduction

The JAX-WS reference implementation (RI) used to be dependent on the JAXB RI for databinding. JAXB and JAX-WS implementations have been decoupled, and databinding is now modular. The Eclipselink JAXB implementation, plus EclipseLink extensions, is called MOXy. The `org.eclipse.persistence.moxy.jar` file is bundled with GlassFish Server, which supports the JAXB RI and MOXy as databinding providers. For standalone distributions, databinding plugins can be found in `lib/plugins` folder in the distribution. The MOXy implementation (library) is not bundled with JAX-WS. It's expected from user to provide MOXy jars to classpath whenever MOXy databinding is required. EclipseLink JAXB compiler is not included as well, but can be used with GlassFish Server. Download the EclipseLink zip file at http://www.eclipse.org/eclipselink/downloads/ and unzip it.

## Configure databinding for JVM

To specify the databinding provider for the JVM, set the `com.sun.xml.ws.spi.db.BindingContextFactory` JVM property to one of the following values:

- `com.sun.xml.ws.db.glassfish.JAXBRIContextFactory` Specifies the JAXB reference implementation. This is the default.
- `com.sun.xml.ws.db.toplink.JAXBContextFactory` Specifies the EclipseLink MOXy JAXB binding.

For example:

`asadmin create-jvm-options -Dcom.sun.xml.ws.spi.db.BindingContextFactory=com.sun.xml.ws.db.toplink.JAXBContextFactory`

## Configure databinding for an endpoint

To specify the databinding provider for a web service endpoint:

- Set the `com.oracle.webservices.api.databinding.DatabindingModeFeature` feature during `WebServiceFeature` list initialization or using the `add` method. Allowed values are as follows:
  - `com.oracle.webservices.api.databinding.DatabindingModeFeature.GLASSFISH_JAXB` Specifies the JAXB reference implementation. This is the default.
  - `com.sun.xml.ws.db.toplink.JAXBContextFactory.ECLIPSELINK_JAXB` Specifies Eclipselink MOXy JAXB binding.
  For example:

      import javax.xml.ws.WebServiceFeature;
      import com.oracle.webservices.api.databinding.DatabindingModeFeature;
      import com.sun.xml.ws.db.toplink.JAXBContextFactory;
      ...
      WebServiceFeature[] features = { new DatabindingModeFeature(JAXBContextFactory.ECLIPSELINK_JAXB)};

- Set the `com.oracle.webservices.api.databinding.DatabindingModeFeature` feature using the `@DatabindingMode` annotation. For example:

      import javax.jws.WebService;
      import com.oracle.webservices.api.databinding.DatabindingMode;
      import com.sun.xml.ws.db.toplink.JAXBContextFactory;
      ...
      @WebService
      @DatabindingMode(JAXBContextFactory.ECLIPSELINK_JAXB);

- Set the `databinding` attribute of the endpoint element in the `sun-jaxws.xml` file. Allowed values are `glassfish.jaxb` or `eclipselink.jaxb`. For example:

      <endpoint
          name='hello'
          implementation='hello.HelloImpl'
          url-pattern='/hello'
          databinding='eclipselink.jaxb'/>