viernes, 11 de agosto de 2017

Sellar xml con FirmaSat


sMiArchivo1 is string = EDT_XMLFile
sMiArchivo2 is string = EDT_XMLFile + "1"

////
//hInst = LoadDLL("diFirmaSAT2.DLL")
//IF hInst = 0 THEN
// Error("Error al cargar dll")
//ELSE
// nResultado = CallDLL32("diFirmaSAT2", "SAT_GetCertNumber", sPbuf, nLongitud,EDT_CertFile,
// nOpcion)
// EDT_noCertificado = sPbuf
// nResultado = CallDLL32("diFirmaSAT2", "SAT_GetCertAsString", sP2buf, nL2ongitud,EDT_CertFile,
// nOpcion)
// EDT_Certificado = sP2buf
// FreeDLL(hInst)
//END
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sP2buf is string  = Charact(0)
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
nL2ongitud is int = 20

hInst = LoadDLL("diFirmaSAT2.DLL")
IF hInst = 0 THEN
 Error("Error al cargar dll para colocar sello en el XML")
ELSE
 //extraigo el numero de certificado

 //nResultado = CallDLL32("diFirmaSAT2","SAT_GetCertAsString",sPbuf,nLongitud,EDT_Certificado,nOpcion)
 //nResultado = CallDLL32("diFirmaSAT2","SAT_GetCertNumber",sPbuf,nL2ongitud,EDT_Certificado,nOpcion)
 nResultado = CallDLL32("diFirmaSAT2","SAT_QueryCert",sPbuf,nL2ongitud,EDT_Certificado,"serialNumber", nOpcion)

 EDT_respuesta = sPbuf

 //Info(Left(sPbuf,20))
 nResultado = CallDLL32("diFirmaSAT2", "SAT_ValidateXml", sMiArchivo1, nOpcion)
 IF nResultado <> 0 THEN
  Info("ERROR", "SAT_ValidateXML regresa el valor: " + nResultado + " fallidamente")
 ELSE
  nResultado = CallDLL32("diFirmaSAT2", "SAT_SignXml", sMiArchivo2, sMiArchivo1, EDT_Llave,EDT_password,EDT_Certificado,nOpcion)
  IF nResultado <> 0 THEN
   Info("ERROR AL SELLAR EL XML","RESULTADO :" + nResultado)
  ELSE
   nResultado = CallDLL32("diFirmaSAT2", "SAT_VerifySignature", sMiArchivo2, sP2buf,nOpcion)
   IF nResultado <> 0 THEN
    Info("Verificación Fallida de Firma" + sMiArchivo2, "returns: " + nResultado)
   END
  END
 END
 FreeDLL(hInst)
END


2 comentarios:

  1. nResultado = CallDLL32("diFirmaSAT2","SAT_QueryCert",sPbuf,nL2ongitud,EDT_Certificado,"serialNumber", nOpcion) te funcionó esta linea? me dice que no es el número de parámetros que espera

    ResponderBorrar
    Respuestas
    1. Que versión tienes de firmasat? Ya resolviste el problema??

      Borrar

Try catch end

 // -------------------------------------------------- // Procedure principal que executa uma query com tratamento de exceção // -----------...