title: Apache CXF: Duplicate default namespace declaration
body: <p>I'm having a problem with Apache CXF. Basically, it's turning this:</p>
  
  <pre><code>&lt;consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00"&gt;
  </code></pre>
  
  <p>Into this:</p>
  
  <pre><code>&lt;consStatServ xmlns:ns2="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns="" xmlns="" xmlns:ns5="http://www.portalfiscal.inf.br/nfe" versao="2.00"&gt;
  </code></pre>
  
  <p>Causing an "Duplicate default namespace declaration" exception.</p>
  
  <p>This is my Spring configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
  xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:cxf="http://cxf.apache.org/core"
  xsi:schemaLocation="http://www.springframework.org/schema/beans  
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/tx 
         http://www.springframework.org/schema/tx/spring-tx.xsd
         http://cxf.apache.org/configuration/security
         http://cxf.apache.org/schemas/configuration/security.xsd
         http://cxf.apache.org/jaxws 
         http://cxf.apache.org/schemas/jaxws.xsd
         http://cxf.apache.org/transports/http/configuration
         http://cxf.apache.org/schemas/configuration/http-conf.xsd
         http://cxf.apache.org/core 
         http://cxf.apache.org/schemas/core.xsd"&gt;
  
  &lt;jaxws:client id="nfeStatusServicoMGWebService"
      serviceClass="com.ats.nfe.webservice.mg.NfeStatusServico2Soap12"
      address="https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeStatus2"&gt;
      &lt;jaxws:inInterceptors&gt;
          &lt;bean class="org.apache.cxf.interceptor.LoggingInInterceptor"&gt;
          &lt;/bean&gt;
      &lt;/jaxws:inInterceptors&gt;
      &lt;jaxws:outInterceptors&gt;
          &lt;bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"&gt;
          &lt;/bean&gt;
      &lt;/jaxws:outInterceptors&gt;
  &lt;/jaxws:client&gt;
  
  
  &lt;http:conduit
      name="{http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2}NfeStatusServico2Soap12Port.http-conduit"&gt;
  
      &lt;http:tlsClientParameters&gt;
          &lt;sec:keyManagers keyPassword="password"&gt;
              &lt;sec:keyStore type="JKS" password="123456"
                  file="C:/Documents and Settings/HaroldoOliveira/teste.jks" /&gt;
          &lt;/sec:keyManagers&gt;
          &lt;sec:trustManagers&gt;
              &lt;sec:keyStore type="JKS" password="123456"
                  file="C:/Documents and Settings/HaroldoOliveira/truststore_nfe.jks" /&gt;
          &lt;/sec:trustManagers&gt;
          &lt;sec:cipherSuitesFilter&gt;
              &lt;!-- these filters ensure that a ciphersuite with export-suitable or 
                  null encryption is used, but exclude anonymous Diffie-Hellman key change 
                  as this is vulnerable to man-in-the-middle attacks --&gt;
              &lt;sec:include&gt;.*_EXPORT_.*&lt;/sec:include&gt;
              &lt;sec:include&gt;.*_EXPORT1024_.*&lt;/sec:include&gt;
              &lt;sec:include&gt;.*_WITH_DES_.*&lt;/sec:include&gt;
              &lt;sec:include&gt;.*_WITH_NULL_.*&lt;/sec:include&gt;
              &lt;sec:exclude&gt;.*_DH_anon_.*&lt;/sec:exclude&gt;
          &lt;/sec:cipherSuitesFilter&gt;
      &lt;/http:tlsClientParameters&gt;
      &lt;http:client AutoRedirect="true" Connection="Keep-Alive" /&gt;
  
  &lt;/http:conduit&gt;
  
  &lt;cxf:bus&gt;
      &lt;cxf:features&gt;
          &lt;cxf:logging/&gt;
      &lt;/cxf:features&gt;
  &lt;/cxf:bus&gt; 
  </code></pre>
  
  <p></p>
  
  <p>And this is my test code:</p>
  
  <pre><code>public class NFeCXFTest {
  
  private static String XML_TESTE_STATUS =
      "&lt;consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"2.00\"&gt;" +
      "    &lt;tpAmb&gt;2&lt;/tpAmb&gt;" +
      "    &lt;cUF&gt;31&lt;/cUF&gt;" +
      "    &lt;xServ&gt;STATUS&lt;/xServ&gt;" +
      "&lt;/consStatServ&gt;";
  
  
  private NfeStatusServico2Soap12 statusServ;
  
  @Test
  public void commitNfeStatusServicoNF() {
      NfeCabecMsg cabec = new NfeCabecMsg();
      cabec.setCUF("31");
      cabec.setVersaoDados("2.00");
  
      NfeDadosMsg dados = new NfeDadosMsg();
      try {
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          InputSource is = new InputSource();
          is.setCharacterStream(new StringReader(XML_TESTE_STATUS));
          Document contentDoc = db.parse(is);
          dados.getContent().add(contentDoc.getDocumentElement());
      } catch (ParserConfigurationException e) {
          throw new IllegalArgumentException("Erro ao empacotar o conteúdo, ", e);
      } catch (SAXException e) {
          throw new IllegalArgumentException("Erro ao empacotar o conteúdo, ", e);
      } catch (IOException e) {
          throw new IllegalArgumentException("Erro ao empacotar o conteúdo, ", e);
      }           
  
      NfeStatusServicoNF2Result ret = this.statusServ.nfeStatusServicoNF2(dados, cabec);
      Object retVal = ret.getContent().iterator().next();
      System.out.println(retVal.getClass());
      System.out.println("***.***.***");
  
      try {
          Result stringResult = new StringResult();
          TransformerFactory tFactory = TransformerFactory.newInstance();
          Transformer transformer = tFactory.newTransformer();
          transformer.transform(new DOMSource((Node)retVal), stringResult);
          System.out.println("O retorno é: " + stringResult);
      } catch (TransformerException e) {
          throw new IllegalArgumentException("Impossível gerar nova requisição, ", e);
      }
  }
  
  @Resource(name="nfeStatusServicoMGWebService")
  public void setStatusServ(NfeStatusServico2Soap12 statusServ) {
      this.statusServ = statusServ;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any ideas on what I'm doing wrong?</p>