Requiero utilizar la lib curl version 8.12, para poder usar cerificados .p12
Para poder probar el ejemplo publicado por antonio para enviar facturas electronicas
Ejp.. adaptado para la DIAN Colombia
JONSSON RUSSI
Code: Select all | Expand
#include "FiveWin.ch"
#include "hbcurl.ch"
#include "xbrowse.ch"
function main()
local cUrl := "https://vpfe.dian.gov.co/WcfDianCustomerServices.svc"
local cSignedXmlFile := "E:\TEMP\XML_FIRMADO\z006331767200025SP104100000250_fv_B64"
local cNomZip := "z006331767200025SP104100000250.zip"
EnviarFactura( cUrl, cSignedXmlFile,cNomZip )
return
function EnviarFactura( cUrl, cSignedXmlFile, cNomZip )
local hCurl, cSoapRequest, cSoapResponse, cFacturaXml
local hResponse, uValue, nHttpCode
local cPasCer := "russoft"
cFilCer := "E:\ZERUS\FIRMA_ELECTRONICA\CERT\certificado_29.p12"
cClaCer := "cxxxxxxxxxxxxx"
cFacturaXml = MemoRead( cSignedXmlFile )
// Crear la solicitud SOAP
cSoapRequest = ;
'<?xml version="1.0" encoding="UTF-8"?>' + ;
'<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wcf="http://wcf.dian.colombia">' + ;
'<soapenv:Header/>'+;
'<soapenv:Body>' + ;
'<wcf:SendBillSync>' + ;
'<wcf:fileName>' + cNomZip +'</wcf:fileName>' + ;
'<wcf:contentFile>' + cFacturaXml + '</wcf:contentFile>' + ;
'</wcf:SendBillSync>' + ;
'</soapenv:Body>' + ;
'</soapenv:Envelope>'
HB_MEMOWRIT( "PRUEBA.XML", cSoapRequest )
hCurl = curl_easy_init()
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, cSoapRequest )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, { "Content-Type: application/soap+xml; charset=utf-8", "SOAPAction: http://wcf.dian.colombia/IWcfDianCustomerServices/SendBillSync" } )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_SSLCERT, cFilCer )
curl_easy_setopt( hCurl, HB_CURLOPT_SSLCERTPASSWD, cClaCer )
cSoapResponse = curl_easy_perform( hCurl )
if Empty( cSoapResponse )
MsgStop( "Error al enviar la factura." )
else
MsgInfo( "Respuesta del servidor: " + if(valtype(cSoapResponse)=="C",cSoapResponse,STR(cSoapResponse) ) )
endif
curl_easy_cleanup( hCurl )
return nil