Bonjour à tous,
j'essaie de parser un fichier XML et de le transformer en javabeans avec JAXB.
Mon fichier XML a des préfixes de namespace comme ceci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
<?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>
Mais je n'arrive pas à configurer JAXB dans mon fichier cxf.xml pour lui faire supporter mes namespaces...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    <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, notez que le même fichier XML sans les namespaces fonctionne sans problème...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
<?xml version="1.0" encoding="iso-8859-1"?>
 
<mutation>
 <event>
  <code>123</code>
  <person>
    <id>456</id>
  </person>
  </event>
</mutation>