Hi, On 08/26/2011 10:33 PM, Raphael Vullriede wrote: > Hi, > > I'm building a JAX-RS service with CXF 2.4.2 and JAXB for the bindings > (Java 1.6.0_26). > > My response contains elements from two namespaces and it is correctly > rendered. > The second namespace gets automatically the prefix "ns2" which I have to > change to something more "meaningful" for a third-party component. > > I found http://cxf.apache.org/docs/jaxb.html that mentioned something > like this for JAX-WS: > > <util:map id="namespace2Prefix" map-class="java.util.HashMap"> > <entry key="myPrimaryNameSpace" value=""/> > <entry key="mySecondaryNamespace" value="ip"/> > </util:map> > > <jaxws:server....> > <jaxws:dataBinding> > <bean class="org.apache.cxf.jaxb.JAXBDataBinding"> > <property name="namespaceMap" ref="namespace2Prefix" /> > </bean> > </jaxws:dataBinding> > </jaxws:server> > > I tried the same for JAXRS but it does not seems to work: > > <jaxrs:server...> > <jaxrs:dataBinding> > <bean class="org.apache.cxf.jaxb.JAXBDataBinding"> > <property name="namespaceMap" ref="namespace2Prefix" /> > </bean> > </jaxrs:dataBinding> > </jaxrs:server> > > I also tried this: > > <bean id="xmlDataBinding" class="org.apache.cxf.jaxb.JAXBDataBinding"> > <property name="namespaceMap" ref="namespace2Prefix" /> > </bean> > > <bean id="xmlDataBindingProvider" > class="org.apache.cxf.jaxrs.provider.DataBindingProvider"> > <property name="dataBinding" ref="xmlDataBinding" /> > </bean> > > > But it does not work either and I don't find anything useful in the > logs. Do I miss something? > > Thanks, > Raphael
For now I solved it by following the solution described here: http://hwellmann.blogspot.com/2011/03/jaxb-marshalling-with-custom-namespace.html: package-info.java: @javax.xml.bind.annotation.XmlSchema( namespace = "http://mySecondaryNamespace", xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "prefix", namespaceURI = "http://mySecondaryNamespace" ) }, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package com.example.package; and disabled the generation of the file by adding -npa to the jaxb2-plugin configuration. That works well but I still wonder why the first two approaches don't work. Thanks, Raphael
