Jump to content

Delphi chamada_delphi.png acbr.png

C6 chamada_c6.png botao.png

Assinar XML SNCM da ANVISA utilizando ACBr


Go to solution Solved by sprdata,

Recommended Posts

Gostaria de uma ajuda para utilizar o ACBrDFeSSL na assinatura do arquivo SNCM da ANVISA.

Criei a seguinte procedure

 

procedure TForm1.Assinar(XML: String);
var
  slXML: TStringList;
  Assinartura: TDFeSSL;
  sXML: AnsiString;
  i: Integer;
begin
  try
    slXML := TStringList.Create;
    Assinartura := TDFeSSL.Create;
    Assinartura.SSLXmlSignLib := xsMsXml;
    slXML.Clear;
    slXML.Text := XML;
    sXML := '';
    for i := 0 to slXML.Count-1 do
    begin
      sXML := sXML + Trim(
        StringReplace(
          StringReplace(slXML[i], #13, '', [rfReplaceAll]),
          #10, '', [rfReplaceAll]
        )
      )
    end;
    Text := Assinartura.Assinar(sXML, '', '');
    
    slXML.SaveToFile('c:\xx\NovoXMLAssinado.xml');
  finally
    slXML.Clear;
    FreeAndNil(slXML);
    Assinartura.Free;
  end;

 

Mas ao tentar executar a rotina recebo o seguinte erro:

DadosPFX, ArquivoPFX, URLPFX ou NumeroSerie não especificados !

Segue o XML
 

<msgEvtIn xmlns="http://sncm.anvisa.gov.br/">
<docId>LSA097PLFO9F03IY81JJ</docId>
<ccTime>2021-05-17T09:01:51Z</ccTime>
<ver>0.01</ver>
<lc>pt-BR</lc>
<env>2</env>
<declarant>
<cnpj>XXXXXXXXXXXXXX</cnpj>
</declarant>
<mbrAgt>XXXXXXXXXXXXXX</mbrAgt>
<usrAgt>Foo Bar - v1.0.1 - TEL: 11 9 1234-5678 - [email protected]</usrAgt>
<evts>
<shpt>
<evtNotifId>LSA097PLFO9F03IY81JJ</evtNotifId>
<pastTime>2020-12-29T15:16:52Z</pastTime>
<fit>false</fit>
<prtnr>
<cnpj>XXXXXXXXXXXXXX</cnpj>
</prtnr>
<carrs>
<car>
<cnpj>XXXXXXXXXXXXXX</cnpj>
</car>
</carrs>
<pld>
<tp>
<tpi>
<sscc>112345678000001811</sscc>
</tpi>
<pld>
<dui>
<gtin>01234567891019</gtin>
<serl>1152762682851</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891019</gtin>
<serl>1149973801142</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891019</gtin>
<serl>1461818578292</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
</pld>
</tp>
<tp>
<tpi>
<gtinSn>012345678910191152762682851</gtinSn>
</tpi>
<pld>
<dui>
<gtin>01234567891026</gtin>
<serl>1346162133420</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1042690843028</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1562535839091</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1078111657439</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1862908137618</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1134338568065</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1000970627886</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1327104081817</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1720832031255</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1896641478317</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
</pld>
</tp>
<tp>
<tpi>
<gtinSn>012345678910191149973801142</gtinSn>
</tpi>
<pld>
<dui>
<gtin>01234567891026</gtin>
<serl>1929112766512</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1909302687813</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1643621536373</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1853776356704</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1332907967531</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1068781565938</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1389696611107</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1553143330167</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1428962874808</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1006250176880</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
</pld>
</tp>
<tp>
<tpi>
<gtinSn>012345678910191461818578292</gtinSn>
</tpi>
<pld>
<dui>
<gtin>01234567891026</gtin>
<serl>1378226369306</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1093852346251</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1138843568714</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1071149544391</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1144014466648</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1580648121219</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1446908855808</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1238422676262</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1821426424631</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
<dui>
<gtin>01234567891026</gtin>
<serl>1027550879615</serl>
<exp>2021-12</exp>
<lot>LOT001</lot>
</dui>
</pld>
</tp>
</pld>
<bizTrans>
<bizTransId>90723641642768274750907236416427682747501234 </bizTransId>
<bizTransType>NFe</bizTransType>
</bizTrans>
</shpt>
</evts>
</msgEvtIn>

Se alguém tiver um dica agradeço!
Link to comment
Share on other sites

  • Administradores

Bom dia,

Não ficou claro qual é a sua dúvida.

At.

Consultora SAC ACBr

Juliana Tamizou
Ajude o Projeto ACBr crescer - Assine o SAC

Projeto ACBr     Telefone:(15) 2105-0750 WhatsApp(15)99790-2976.  Discord

Projeto ACBr - A maior comunidade Open Source de Automação Comercial do Brasil


Participe de nosso canal no Discord e fique ainda mais próximo da Comunidade !!

Link to comment
Share on other sites

  • Solution

@Josimar Bezerra Ficou faltando vc informar o Certificado digital para assinatura...

Mas ao tentar executar a rotina recebo o seguinte erro:

"DadosPFX, ArquivoPFX, URLPFX ou NumeroSerie não especificados !"

Verifica ai se vc informou corretamente o Certificado Digital é só isso que esta faltando...

 

 

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.