Hi Raphael

I've added a namespacePrefixes property to JAXBElementProvider, so starting from 2.4.3 it will be easier to customize the prefixes when really needed. I also tried JAXRSDataBindingTest (in systest/jaxrs) and updated the relevant spring config to add a property to the databinding the way you did it and updated Book class used in the test to have a namespace - that worked for me. Not sure why it did not for you - one possibility is that you have resource methods returning explicit collections - JAXRS does not generate wrappers so would not add a relevant class to the total JAXB context...

thanks, Sergey

On 26/08/11 21:33, 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

Reply via email to