Comments below.

> -----Original Message-----
> From: KARR, DAVID (ATTCINW)
> Sent: Friday, September 04, 2009 9:29 AM
> To: [email protected]
> Subject: Starting to investigate schema-driven bindings with JAXRS
> 
> I now have a trivial prototype using JAXRS.  I now want to investigate
> adding some elements of realism :) , by adding schema-driven bindings,
> even from fake schemas.  My current prototype uses a hand-written
> "@XmlRootElement" annotation on the class that represents the root of
> the response message.  I'd like to investigate how to define the root
> element and bindings in Spring and associated configuration files.  I
> see some scattered pieces of how to do this, but I'm having some
> trouble
> figuring out how these pieces fit together.  I know that CXF uses JAXB
> by default, although XMLBeans is an option.  Why would someone choose
> one over the other?
> 
> I see examples of a "jaxws:dataBinding" element in various samples, but
> the "jaxrs" samples don't do anything like that.   Can I simply have a
> "jaxws:dataBinding" element inside the "jaxrs:server" element?
> 
> I see the documentation briefly mentions (with no examples) that
> specifying a "jaxbElementClassNames" property is how you could use
> element classes that you can't add "@XmlRootElement" annotations to
> (like, if they were generated).  There's barely any mention of that
> property name in the entire CXF distribution.

I also noticed the following in the JAX-RS section of the manual (note the 
obvious typo :) ):
--------
Support for CXF DataBingings

Starting from CXF 2.2.3 it is now possible to register a CXF DataBinding bean 
using a jaxrs:databinding element and it will be wrappped as a JAXRS 
MessageBodyReader/Writer provider capable of dealing with XML-based content. It 
can be of special interest to users combining JAX-RS and JAXWS. Thus CXF JAXB, 
Aegis, SDO and XMLBeans databindings can be easily plugged in.
JSON support is also available for all these databindings.
Please see this configuration file for some examples.

Similarly to the default JSONProvider these DataBinding-aware JSON provider can 
have "namespaceMap", "serializeAsArray", "arrayKeys", "dropRootElement" and 
"writeXsiType" properties set. Additionally they may also have an 
"ignoreMixedContent" property set.

Note that at the moment this feature is not available when a cxf-jaxrs bundle 
is used (except for Aegis).
--------------

The "Please see this configuration file" is a link to < 
http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml>,
 which this is an excerpt of:
--------------
<jaxrs:server id="jaxbbook" address="/jaxb">
−
<jaxrs:serviceBeans>
<ref bean="serviceBean"/>
</jaxrs:serviceBeans>
−
<jaxrs:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding"/>
</jaxrs:dataBinding>
</jaxrs:server>
--------------

Here's a "jaxrs:dataBinding" element, but I don't see that in the current jaxrs 
schema.

Reply via email to