viernes, 11 de agosto de 2017

Timbrando con Facturador Electrónico

bufMessageXML is Buffer
sFacturaXML is string
ResExecute is boolean
sRespuesta is string
sResultado1 is string
sMiarchivo4 is string = "c:\temp\MiCfdi4.xml" //archivo completo de respuesta del pac
sMiarchivo5 is string = "c:\temp\MiCfdi5.xml" //timbre obtenido del pac

// Create
sFacturaXML = fLoadText(EDT_File,foAnsi)
bufMessageXML = ...
"<?xml version=""1.0"" encoding=""utf-8"" ?>" + ...
"<soap:Envelope xmlns:soap=""http://www.w3.org/2003//05/soap-envelope/""" + ...
" xmlns:tim=""http://facturadorelectronico.com/timbrado"">" + ...
" <soap:Header/>" + ...
" <soap:Body>"  + ...
"<tim:obtenerTimbrado>" + ...
"<tim:CFDIcliente>" + "<![CDATA["+sFacturaXML + "]]> " + "</tim:CFDIcliente>" + ...
"<tim:Usuario>test</tim:Usuario>" + ...
"<tim:password>TEST</tim:password>" + ...
"</tim:obtenerTimbrado></soap:Body></soap:Envelope>"
//
Info(bufMessageXML)
//https://stagetimbrado.facturador.com/timbrado.asmx
//http://facturadorelectronico.com/timbrado/obtenerTimbrado
sURL is string = URLEncode("https://stagetimbrado.facturador.com/timbrado.asmx")
sAccion is a string = URLEncode("http://facturadorelectronico.com/timbrado/obtenerTimbrado")

//HTTPCertificate(
// Run the procedure
//ResExecute = SOAPRunXML(sURL ,bufMessageXML,sAccion)
ResExecute = SOAPRunXML("https://stagetimbrado.facturador.com/timbrado.asmx",bufMessageXML,sAccion)
IF ResExecute = True THEN // Is the communication with the server successful?
 // Is the procedure successfully run?
 sRespuesta = SOAPGetResult(SOAPXMLResult)
 fSaveText(sMiarchivo4,sRespuesta)
 IF sRespuesta <> "" THEN
  //Info(sRespuesta) // Display the result returned by the procedure
 ELSE
  Error("El error es: " + SOAPError(SOAPErrMessage))
  // Display the error returned by the SOAP server
 END
ELSE
 Error("No hay respuesta del servidor", ErrorInfo(errMessage),ResExecute)
END
sResultado1 = XMLExtractString(sRespuesta,"obtenerTimbradoResult",1,XMLExact)
Message(sResultado1)

No hay comentarios.:

Publicar un comentario

Try catch end

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