You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID (ATTCINW)" <dk...@att.com> on 2009/09/08 22:10:34 UTC

Can JAXB bindings be placed inside "jaxrs:bindings"?

If I need to customize the Java->XML binding by creating a
"jaxb:bindings" element, where would I put that?  Would it go in the
"jaxrs:bindings" element that is contained within the "jaxrs:server"
element?  If so, is this possible in 2.2.3, or only in the trunk?

RE: Can JAXB bindings be placed inside "jaxrs:bindings"?

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
> 
> jaxrs:binding is reserved for plugging in alternative binding
> implementations. For example it is the XMLBinding which is used by the
> JAXRS
> runtime under the hood.
> 
> Are the properties declared by jaxb:bindings meant to be set on JAXB
> Marshaller ? If yes then you can set a marshallerProperties map
> property on
> a JAXBElementProvider.

The following is an excerpt from an example I found in the CXF source
tree that shows the kind of things you might do in "jaxb:bindings":

--------------
<jaxws:bindings wsdlLocation="hello_world.wsdl"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	node="wsdl:definitions/wsdl:types/xsd:schema">
	<jaxb:bindings version="2.0"
node="xsd:element[@name='CreateProcess']/xsd:complexType/xsd:sequence/xs
d:element[@name='MyProcess']/xsd:simpleType">
		<jaxb:typesafeEnumClass name="MyProcess">
			<jaxb:typesafeEnumMember name="BLUE"
value="BLUE" />
			<jaxb:typesafeEnumMember name="RED" value="RED"
/>
			<jaxb:typesafeEnumMember name="GREEN"
value="GREEN" />
		</jaxb:typesafeEnumClass>
	</jaxb:bindings>
</jaxws:bindings>
--------------

What I'm not sure about is whether these constructs just control code
generation, or whether it can be used to modify the XML structure that
is used when marshalling an instance to XML.

> KARR, DAVID (ATTCINW) wrote:
> >
> > If I need to customize the Java->XML binding by creating a
> > "jaxb:bindings" element, where would I put that?  Would it go in the
> > "jaxrs:bindings" element that is contained within the "jaxrs:server"
> > element?  If so, is this possible in 2.2.3, or only in the trunk?

Re: Can JAXB bindings be placed inside "jaxrs:bindings"?

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

jaxrs:binding is reserved for plugging in alternative binding
implementations. For example it is the XMLBinding which is used by the JAXRS
runtime under the hood. 

Are the properties declared by jaxb:bindings meant to be set on JAXB
Marshaller ? If yes then you can set a marshallerProperties map property on
a JAXBElementProvider. 

Dan, is is possible to configure jaxb:bindings using a JAXBDataBinding bean
? If yes then is it JAXBContext properties that they translate to ? Or
Marshaller properties ?

David, one possible JAXRS specific option which might also help is to
register a CustomContextResolver<JAXBContext> which implements JAXRS
ContextResolver and JAXBElementProvider will check this resolver for
contexts for individual classes....

cheers, Sergey


KARR, DAVID (ATTCINW) wrote:
> 
> If I need to customize the Java->XML binding by creating a
> "jaxb:bindings" element, where would I put that?  Would it go in the
> "jaxrs:bindings" element that is contained within the "jaxrs:server"
> element?  If so, is this possible in 2.2.3, or only in the trunk?
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-JAXB-bindings-be-placed-inside-%22jaxrs%3Abindings%22--tp25353232p25367897.html
Sent from the cxf-user mailing list archive at Nabble.com.