You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Fernando Silva <fs...@synchro.com.br> on 2013/05/17 21:15:09 UTC

CXF changing the XMLDSIG prefixes

Hi,

 

I'm doing some tests, in which I add the following XML (Signed XML) in SOAP
message:

 

<?xml version="1.0" encoding="UTF-8"?>

<inutNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">

  <infInut Id="ID35130929629500024055001042708314042708414">

    <tpAmb>2</tpAmb>

    <xServ>INUTILIZAR</xServ>

    <cUF>35</cUF>

    <ano>13</ano>

    <CNPJ>09296295000240</CNPJ>

    <mod>55</mod>

    <serie>1</serie>

    <nNFIni>42708314</nNFIni>

    <nNFFin>42708414</nNFFin>

    <xJust>Numero nao utilizado pelo sistema.</xJust>

  </infInut>

  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">

    .

    .

    .

  </Signature>

</inutNFe>

 

 

But after put the XML in the Soap Envelope Body, CXF changes the XML adding
namespaces and prefixes:

 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">

  <soap:Header>

    <ns2:nfeCabecMsg
xmlns:ns2="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2"
xmlns="http://www.portalfiscal.inf.br/nfe">

      <ns2:cUF>35</ns2:cUF>

      <ns2:versaoDados>2.00</ns2:versaoDados>

    </ns2:nfeCabecMsg>

  </soap:Header>

  <soap:Body>

    <ns2:nfeDadosMsg xmlns=" <http://www.portalfiscal.inf.br/nfe>
http://www.portalfiscal.inf.br/nfe" xmlns:ns2="
<http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2>
http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2">

      <inutNFe versao="2.00">

        <infInut Id="ID35130929629500024055001042708314042708414">

          <tpAmb>2</tpAmb>

          <xServ>INUTILIZAR</xServ>

          <cUF>35</cUF>

          <ano>13</ano>

          <CNPJ>09296295000240</CNPJ>

          <mod>55</mod>

          <serie>1</serie>

          <nNFIni>42708314</nNFIni>

          <nNFFin>42708414</nNFFin>

          <xJust>Numero nao utilizado pelo sistema.</xJust>

        </infInut>

        <Signature:Signature
xmlns:Signature="http://www.w3.org/2000/09/xmldsig#"
xmlns="http://www.w3.org/2000/09/xmldsig#">

          .

          .

          .

        </Signature:Signature>

      </inutNFe>

    </ns2:nfeDadosMsg>

  </soap:Body>

</soap:Envelope>

 

 

Why CXF changes the original XML?

 

I need to remove this namespace and prefix, how can I do this?

 

Regards,

Fernando Cesar

 

 


RE: CXF changing the XMLDSIG prefixes

Posted by Andrei Shakirin <as...@talend.com>.
Hi Fernando,

Colm means that, accordingly WS-Security, signature of message body or body elements should be placed into SOAP security header, not SOAP body.
Do you have good reasons not to use CXF security features to sign your message elements and do it manually?

Regarding your problem: changing prefix in your message can be caused by JAXB or low level XML libraries - I am not sure. 
You can try to resolve it through bindings or transformations, but to be honest IMO it is not good solution.

Regards,
Andrei.

> -----Original Message-----
> From: Fernando Silva [mailto:fsilva@synchro.com.br]
> Sent: Montag, 20. Mai 2013 15:57
> To: users@cxf.apache.org; coheigea@apache.org
> Cc: 'Diogo Gallo'; 'Joselito Viana'
> Subject: RES: CXF changing the XMLDSIG prefixes
> 
> Hi Colm,
> 
> I'm calling a service that receive a String parameter and this String has to be a
> signed XML, i.e., the parameter content is signed, not the entire
> Envelope(don't know if this is possible).
> 
> I think the problem is the way JAXB is handling namespaces. The parameter
> I'm talking about is the nfeDadosMsg, that is defined as below....
> 
> 
>   <wsdl:types>
>     <s:schema elementFormDefault="qualified"
> targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2
> ">
>       <s:element name="nfeDadosMsg">
>         <s:complexType mixed="true">
>           <s:sequence>
>             <s:any />
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="nfeInutilizacaoNF2Result">
>         <s:complexType mixed="true">
>           <s:sequence>
>             <s:any />
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="nfeCabecMsg" type="tns:nfeCabecMsg" />
>       <s:complexType name="nfeCabecMsg">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="1" name="cUF" type="s:string"
> />
>           <s:element minOccurs="0" maxOccurs="1" name="versaoDados"
> type="s:string" />
>         </s:sequence>
>         <s:anyAttribute />
>       </s:complexType>
>     </s:schema>
>   </wsdl:types>
> 
> 
> Any clue will be helpful.
> 
> Fernando.
> 
> -----Mensagem original-----
> De: Colm O hEigeartaigh [mailto:coheigea@apache.org] Enviada em:
> segunda-feira, 20 de maio de 2013 06:25
> Para: users@cxf.apache.org
> Assunto: Re: CXF changing the XMLDSIG prefixes
> 
> I don't know, but you never put the Signature in the SOAP Body, it only ever
> goes in the Security header of the request.
> 
> Colm.
> 
> 
> On Fri, May 17, 2013 at 8:15 PM, Fernando Silva
> <fs...@synchro.com.br>wrote:
> 
> > Hi,
> >
> >
> >
> > I'm doing some tests, in which I add the following XML (Signed XML) in
> > SOAP
> > message:
> >
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <inutNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
> >
> >   <infInut Id="ID35130929629500024055001042708314042708414">
> >
> >     <tpAmb>2</tpAmb>
> >
> >     <xServ>INUTILIZAR</xServ>
> >
> >     <cUF>35</cUF>
> >
> >     <ano>13</ano>
> >
> >     <CNPJ>09296295000240</CNPJ>
> >
> >     <mod>55</mod>
> >
> >     <serie>1</serie>
> >
> >     <nNFIni>42708314</nNFIni>
> >
> >     <nNFFin>42708414</nNFFin>
> >
> >     <xJust>Numero nao utilizado pelo sistema.</xJust>
> >
> >   </infInut>
> >
> >   <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
> >
> >     .
> >
> >     .
> >
> >     .
> >
> >   </Signature>
> >
> > </inutNFe>
> >
> >
> >
> >
> >
> > But after put the XML in the Soap Envelope Body, CXF changes the XML
> > adding namespaces and prefixes:
> >
> >
> >
> > <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-
> envelope">
> >
> >   <soap:Header>
> >
> >     <ns2:nfeCabecMsg
> > xmlns:ns2="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2"
> > xmlns="http://www.portalfiscal.inf.br/nfe">
> >
> >       <ns2:cUF>35</ns2:cUF>
> >
> >       <ns2:versaoDados>2.00</ns2:versaoDados>
> >
> >     </ns2:nfeCabecMsg>
> >
> >   </soap:Header>
> >
> >   <soap:Body>
> >
> >     <ns2:nfeDadosMsg xmlns=" <http://www.portalfiscal.inf.br/nfe>
> > http://www.portalfiscal.inf.br/nfe" xmlns:ns2="
> > <http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2>
> > http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2">
> >
> >       <inutNFe versao="2.00">
> >
> >         <infInut Id="ID35130929629500024055001042708314042708414">
> >
> >           <tpAmb>2</tpAmb>
> >
> >           <xServ>INUTILIZAR</xServ>
> >
> >           <cUF>35</cUF>
> >
> >           <ano>13</ano>
> >
> >           <CNPJ>09296295000240</CNPJ>
> >
> >           <mod>55</mod>
> >
> >           <serie>1</serie>
> >
> >           <nNFIni>42708314</nNFIni>
> >
> >           <nNFFin>42708414</nNFFin>
> >
> >           <xJust>Numero nao utilizado pelo sistema.</xJust>
> >
> >         </infInut>
> >
> >         <Signature:Signature
> > xmlns:Signature="http://www.w3.org/2000/09/xmldsig#"
> > xmlns="http://www.w3.org/2000/09/xmldsig#">
> >
> >           .
> >
> >           .
> >
> >           .
> >
> >         </Signature:Signature>
> >
> >       </inutNFe>
> >
> >     </ns2:nfeDadosMsg>
> >
> >   </soap:Body>
> >
> > </soap:Envelope>
> >
> >
> >
> >
> >
> > Why CXF changes the original XML?
> >
> >
> >
> > I need to remove this namespace and prefix, how can I do this?
> >
> >
> >
> > Regards,
> >
> > Fernando Cesar
> >
> >
> >
> >
> >
> >
> 
> 
> --
> Colm O hEigeartaigh
> 
> Talend Community Coder
> http://coders.talend.com


RES: CXF changing the XMLDSIG prefixes

Posted by Fernando Silva <fs...@synchro.com.br>.
Hi Colm,

I'm calling a service that receive a String parameter and this String has to
be a signed XML, i.e., the parameter content is signed, not the entire
Envelope(don't know if this is possible).

I think the problem is the way JAXB is handling namespaces. The parameter
I'm talking about is the nfeDadosMsg, that is defined as below....


  <wsdl:types>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2">
      <s:element name="nfeDadosMsg">
        <s:complexType mixed="true">
          <s:sequence>
            <s:any />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="nfeInutilizacaoNF2Result">
        <s:complexType mixed="true">
          <s:sequence>
            <s:any />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="nfeCabecMsg" type="tns:nfeCabecMsg" />
      <s:complexType name="nfeCabecMsg">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="cUF" type="s:string"
/>
          <s:element minOccurs="0" maxOccurs="1" name="versaoDados"
type="s:string" />
        </s:sequence>
        <s:anyAttribute />
      </s:complexType>
    </s:schema>
  </wsdl:types>


Any clue will be helpful.

Fernando.

-----Mensagem original-----
De: Colm O hEigeartaigh [mailto:coheigea@apache.org] 
Enviada em: segunda-feira, 20 de maio de 2013 06:25
Para: users@cxf.apache.org
Assunto: Re: CXF changing the XMLDSIG prefixes

I don't know, but you never put the Signature in the SOAP Body, it only ever
goes in the Security header of the request.

Colm.


On Fri, May 17, 2013 at 8:15 PM, Fernando Silva
<fs...@synchro.com.br>wrote:

> Hi,
>
>
>
> I'm doing some tests, in which I add the following XML (Signed XML) in 
> SOAP
> message:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <inutNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
>
>   <infInut Id="ID35130929629500024055001042708314042708414">
>
>     <tpAmb>2</tpAmb>
>
>     <xServ>INUTILIZAR</xServ>
>
>     <cUF>35</cUF>
>
>     <ano>13</ano>
>
>     <CNPJ>09296295000240</CNPJ>
>
>     <mod>55</mod>
>
>     <serie>1</serie>
>
>     <nNFIni>42708314</nNFIni>
>
>     <nNFFin>42708414</nNFFin>
>
>     <xJust>Numero nao utilizado pelo sistema.</xJust>
>
>   </infInut>
>
>   <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
>
>     .
>
>     .
>
>     .
>
>   </Signature>
>
> </inutNFe>
>
>
>
>
>
> But after put the XML in the Soap Envelope Body, CXF changes the XML 
> adding namespaces and prefixes:
>
>
>
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
>
>   <soap:Header>
>
>     <ns2:nfeCabecMsg
> xmlns:ns2="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2"
> xmlns="http://www.portalfiscal.inf.br/nfe">
>
>       <ns2:cUF>35</ns2:cUF>
>
>       <ns2:versaoDados>2.00</ns2:versaoDados>
>
>     </ns2:nfeCabecMsg>
>
>   </soap:Header>
>
>   <soap:Body>
>
>     <ns2:nfeDadosMsg xmlns=" <http://www.portalfiscal.inf.br/nfe>
> http://www.portalfiscal.inf.br/nfe" xmlns:ns2="
> <http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2>
> http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2">
>
>       <inutNFe versao="2.00">
>
>         <infInut Id="ID35130929629500024055001042708314042708414">
>
>           <tpAmb>2</tpAmb>
>
>           <xServ>INUTILIZAR</xServ>
>
>           <cUF>35</cUF>
>
>           <ano>13</ano>
>
>           <CNPJ>09296295000240</CNPJ>
>
>           <mod>55</mod>
>
>           <serie>1</serie>
>
>           <nNFIni>42708314</nNFIni>
>
>           <nNFFin>42708414</nNFFin>
>
>           <xJust>Numero nao utilizado pelo sistema.</xJust>
>
>         </infInut>
>
>         <Signature:Signature
> xmlns:Signature="http://www.w3.org/2000/09/xmldsig#"
> xmlns="http://www.w3.org/2000/09/xmldsig#">
>
>           .
>
>           .
>
>           .
>
>         </Signature:Signature>
>
>       </inutNFe>
>
>     </ns2:nfeDadosMsg>
>
>   </soap:Body>
>
> </soap:Envelope>
>
>
>
>
>
> Why CXF changes the original XML?
>
>
>
> I need to remove this namespace and prefix, how can I do this?
>
>
>
> Regards,
>
> Fernando Cesar
>
>
>
>
>
>


--
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com


Re: CXF changing the XMLDSIG prefixes

Posted by Colm O hEigeartaigh <co...@apache.org>.
I don't know, but you never put the Signature in the SOAP Body, it only
ever goes in the Security header of the request.

Colm.


On Fri, May 17, 2013 at 8:15 PM, Fernando Silva <fs...@synchro.com.br>wrote:

> Hi,
>
>
>
> I'm doing some tests, in which I add the following XML (Signed XML) in SOAP
> message:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <inutNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
>
>   <infInut Id="ID35130929629500024055001042708314042708414">
>
>     <tpAmb>2</tpAmb>
>
>     <xServ>INUTILIZAR</xServ>
>
>     <cUF>35</cUF>
>
>     <ano>13</ano>
>
>     <CNPJ>09296295000240</CNPJ>
>
>     <mod>55</mod>
>
>     <serie>1</serie>
>
>     <nNFIni>42708314</nNFIni>
>
>     <nNFFin>42708414</nNFFin>
>
>     <xJust>Numero nao utilizado pelo sistema.</xJust>
>
>   </infInut>
>
>   <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
>
>     .
>
>     .
>
>     .
>
>   </Signature>
>
> </inutNFe>
>
>
>
>
>
> But after put the XML in the Soap Envelope Body, CXF changes the XML adding
> namespaces and prefixes:
>
>
>
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
>
>   <soap:Header>
>
>     <ns2:nfeCabecMsg
> xmlns:ns2="http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2"
> xmlns="http://www.portalfiscal.inf.br/nfe">
>
>       <ns2:cUF>35</ns2:cUF>
>
>       <ns2:versaoDados>2.00</ns2:versaoDados>
>
>     </ns2:nfeCabecMsg>
>
>   </soap:Header>
>
>   <soap:Body>
>
>     <ns2:nfeDadosMsg xmlns=" <http://www.portalfiscal.inf.br/nfe>
> http://www.portalfiscal.inf.br/nfe" xmlns:ns2="
> <http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2>
> http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2">
>
>       <inutNFe versao="2.00">
>
>         <infInut Id="ID35130929629500024055001042708314042708414">
>
>           <tpAmb>2</tpAmb>
>
>           <xServ>INUTILIZAR</xServ>
>
>           <cUF>35</cUF>
>
>           <ano>13</ano>
>
>           <CNPJ>09296295000240</CNPJ>
>
>           <mod>55</mod>
>
>           <serie>1</serie>
>
>           <nNFIni>42708314</nNFIni>
>
>           <nNFFin>42708414</nNFFin>
>
>           <xJust>Numero nao utilizado pelo sistema.</xJust>
>
>         </infInut>
>
>         <Signature:Signature
> xmlns:Signature="http://www.w3.org/2000/09/xmldsig#"
> xmlns="http://www.w3.org/2000/09/xmldsig#">
>
>           .
>
>           .
>
>           .
>
>         </Signature:Signature>
>
>       </inutNFe>
>
>     </ns2:nfeDadosMsg>
>
>   </soap:Body>
>
> </soap:Envelope>
>
>
>
>
>
> Why CXF changes the original XML?
>
>
>
> I need to remove this namespace and prefix, how can I do this?
>
>
>
> Regards,
>
> Fernando Cesar
>
>
>
>
>
>


-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com