cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cowa <sovattha...@gmail.com>
Subject Re: Namespace prefixing with CXF + JAXB
Date Fri, 27 Feb 2009 10:27:29 GMT

Hi,

I found a solution: generating my Javabeans with a plugin:
"maven-jaxb2-plugin".
It generated my beans and many classes (package-info.java,
ObjectFactory.java) to make my project work even with namespace prefixes.

The problem did not came from the configuration files below.
Best regards,
Sovattha


cowa wrote:
> 
> Hi,
> I'm trying to parse an XML file and turn it into Javabeans with JAXB.
> My XML file has namespace prefixes such as:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <m:mutation xmlns:m="http://namespace1" xmlns:d="http://namespace2">
>  <m:event>
>   <m:code>123</m:code>
>   <d:person>
>     <d:id>456</d:id>
>   </d:person>
>   </m:event>
> </m:mutation>
> 
> But I do not find how to configure JAXB in my cxf.xml file to support my
> namespaces.
> 
>     <jaxws:endpoint id="myService"
>             implementor="ch.MyServiceImpl"
>             address="/ch"
>             bindingUri="http://apache.org/cxf/binding/http">
>         <jaxws:serviceFactory>
>             <bean
> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>                 <property name="wrapped" value="false" />
>             </bean>
>         </jaxws:serviceFactory>
>      <jaxws:dataBinding>
>       <bean class="org.apache.cxf.jaxb.JAXBDataBinding">
>         <property name="namespaceMap">
>             <map>
>                 <entry key="http://namespace1" value="m" />
>             </map>
>         </property>
>       </bean>
>       </jaxws:dataBinding>
>     </jaxws:endpoint>
> 
> Important, note that the same XML file without namespaces:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> 
> <mutation>
>  <event>
>   <code>123</code>
>   <person>
>     <id>456</id>
>   </person>
>   </event>
> </mutation>
> 
> gets parsed without any problem.
> 
> 

-- 
View this message in context: http://www.nabble.com/Namespace-prefixing-with-CXF-%2B-JAXB-tp22223945p22243107.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message