Links: Table of Contents | Single HTML | Single PDF

Chapter 17. Modular Databinding

17.1. 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 in Metro 2.2 release, 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/databinding folder in the distribution. The MOXy implementation (library) is not bundled with Metro. 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.

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

17.3. Configure databinding for an endpoint

To specify the databinding provider for a web service endpoint:

  • Set the org.jvnet.ws.databinding.DatabindingModeFeature feature during WebServiceFeature list initialization or using the add method. Allowed values are as follows:
    • org.jvnet.ws.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 org.jvnet.ws.databinding.DatabindingModeFeature;
    import com.sun.xml.ws.db.toplink.JAXBContextFactory;
    ...
    WebServiceFeature[] features = { new DatabindingModeFeature(JAXBContextFactory.ECLIPSELINK_JAXB)};
                    
  • Set the org.jvnet.ws.databinding.DatabindingModeFeature feature using the @DatabindingMode annotation. For example:
    import javax.jws.WebService;
    import org.jvnet.ws.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'/>
                    
Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20140418.2d69abc)
 
 
Close
loading
Please Confirm
Close