DataFlex
DataFlex
Create SOAP with one VeriFactu Digitally Signed Registration Record
See more Verifactu Examples
Creates a SOAP message containing a single digitally signed invoice registration record, formatted according to the specifications for Spain's Veri*Factu system.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
String sRegistroAlta_id
Handle hoXml
Integer i
Variant vSbSigId
Handle hoSbSigId
Handle hoSbSigValueId
Handle hoSbSignedPropsId
Handle hoSbObjectRefId
Handle hoGen
Handle hoObject1
Variant vCert
Handle hoCert
Variant vSbXml
Handle hoSbXml
Handle hoVerifier
Integer iNumSigs
Integer iVerifyIdx
Boolean iVerified
String sTemp1
Move False To iSuccess
Move True To iSuccess
// Create the following SOAP XML containing one Veri*Factu record to be signed...
// <?xml version="1.0" encoding="UTF-8"?>
// <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
// <soapenv:Header/>
// <soapenv:Body>
// <sum:RegFactuSistemaFacturacion>
// <sum:Cabecera>
// <sum1:ObligadoEmision>
// <sum1:NombreRazon>XYZ STORE SL</sum1:NombreRazon>
// <sum1:NIF>B99999999</sum1:NIF>
// </sum1:ObligadoEmision>
// <sum1:RemisionRequerimiento>
// <sum1:RefRequerimiento>3333333333</sum1:RefRequerimiento>
// <sum1:FinRequerimiento>S</sum1:FinRequerimiento>
// </sum1:RemisionRequerimiento>
// </sum:Cabecera>
// <sum:RegistroFactura>
// <sum1:RegistroAlta Id="001-2020003408">
// <sum1:IDVersion>1.0</sum1:IDVersion>
// <sum1:IDFactura>
// <sum1:IDEmisorFactura>89890001K</sum1:IDEmisorFactura>
// <sum1:NumSerieFactura>12345678-G66</sum1:NumSerieFactura>
// <sum1:FechaExpedicionFactura>03-02-2025</sum1:FechaExpedicionFactura>
// </sum1:IDFactura>
// <sum1:NombreRazonEmisor>certificado uno telematicas</sum1:NombreRazonEmisor>
// <sum1:Subsanacion>N</sum1:Subsanacion>
// <sum1:RechazoPrevio>N</sum1:RechazoPrevio>
// <sum1:TipoFactura>R3</sum1:TipoFactura>
// <sum1:TipoRectificativa>I</sum1:TipoRectificativa>
// <sum1:FacturasRectificadas>
// <sum1:IDFacturaRectificada>
// <sum1:IDEmisorFactura>89890001K</sum1:IDEmisorFactura>
// <sum1:NumSerieFactura>12345600-G66</sum1:NumSerieFactura>
// <sum1:FechaExpedicionFactura>01-04-2024</sum1:FechaExpedicionFactura>
// </sum1:IDFacturaRectificada>
// </sum1:FacturasRectificadas>
// <sum1:FechaOperacion>03-02-2025</sum1:FechaOperacion>
// <sum1:DescripcionOperacion>fecha entrega</sum1:DescripcionOperacion>
// <sum1:Destinatarios>
// <sum1:IDDestinatario>
// <sum1:NombreRazon>certificado dos telematicas</sum1:NombreRazon>
// <sum1:NIF>89890002E</sum1:NIF>
// </sum1:IDDestinatario>
// </sum1:Destinatarios>
// <sum1:Desglose>
// <sum1:DetalleDesglose>
// <sum1:ClaveRegimen>01</sum1:ClaveRegimen>
// <sum1:CalificacionOperacion>S1</sum1:CalificacionOperacion>
// <sum1:TipoImpositivo>4</sum1:TipoImpositivo>
// <sum1:BaseImponibleOimporteNoSujeto>10</sum1:BaseImponibleOimporteNoSujeto>
// <sum1:CuotaRepercutida>0.4</sum1:CuotaRepercutida>
// </sum1:DetalleDesglose>
// <sum1:DetalleDesglose>
// <sum1:ClaveRegimen>01</sum1:ClaveRegimen>
// <sum1:CalificacionOperacion>S1</sum1:CalificacionOperacion>
// <sum1:TipoImpositivo>21</sum1:TipoImpositivo>
// <sum1:BaseImponibleOimporteNoSujeto>100</sum1:BaseImponibleOimporteNoSujeto>
// <sum1:CuotaRepercutida>21</sum1:CuotaRepercutida>
// </sum1:DetalleDesglose>
// <sum1:DetalleDesglose>
// <sum1:ClaveRegimen>05</sum1:ClaveRegimen>
// <sum1:CalificacionOperacion>S1</sum1:CalificacionOperacion>
// <sum1:TipoImpositivo>10</sum1:TipoImpositivo>
// <sum1:BaseImponibleOimporteNoSujeto>100</sum1:BaseImponibleOimporteNoSujeto>
// <sum1:CuotaRepercutida>10</sum1:CuotaRepercutida>
// </sum1:DetalleDesglose>
// </sum1:Desglose>
// <sum1:CuotaTotal>41.4</sum1:CuotaTotal>
// <sum1:ImporteTotal>241.4</sum1:ImporteTotal>
// <sum1:Encadenamiento>
// <sum1:RegistroAnterior>
// <sum1:IDEmisorFactura>89890001K</sum1:IDEmisorFactura>
// <sum1:NumSerieFactura>12345677-G33</sum1:NumSerieFactura>
// <sum1:FechaExpedicionFactura>15-04-2024</sum1:FechaExpedicionFactura>
// <sum1:Huella>C9AF4AF1EF5EBBA700350DE3EEF12C2D355C56AC56F13DB2A25E0031BD2B7ED5</sum1:Huella>
// </sum1:RegistroAnterior>
// </sum1:Encadenamiento>
// <sum1:SistemaInformatico>
// <sum1:NombreRazon>CERTIFICADO UNO TELEMATICAS</sum1:NombreRazon>
// <sum1:NIF>89890001K</sum1:NIF>
// <sum1:NombreSistemaInformatico>NombreSistemaInformatico</sum1:NombreSistemaInformatico>
// <sum1:IdSistemaInformatico>77</sum1:IdSistemaInformatico>
// <sum1:Version>1.0.03</sum1:Version>
// <sum1:NumeroInstalacion>383</sum1:NumeroInstalacion>
// <sum1:TipoUsoPosibleSoloVerifactu>S</sum1:TipoUsoPosibleSoloVerifactu>
// <sum1:TipoUsoPosibleMultiOT>N</sum1:TipoUsoPosibleMultiOT>
// <sum1:IndicadorMultiplesOT>N</sum1:IndicadorMultiplesOT>
// </sum1:SistemaInformatico>
// <sum1:FechaHoraHusoGenRegistro>2025-02-03T14:30:00+01:00</sum1:FechaHoraHusoGenRegistro>
// <sum1:TipoHuella>01</sum1:TipoHuella>
// <sum1:Huella>FF954378B64ED331A9B2366AD317D86E9DEC1716B12DD0ACCB172A6DC4C105AA</sum1:Huella>
// </sum1:RegistroAlta>
// </sum:RegistroFactura>
// </sum:RegFactuSistemaFacturacion>
// </soapenv:Body>
// </soapenv:Envelope>
Move "001-2020003408" To sRegistroAlta_id
Get Create (RefClass(cComChilkatXml)) To hoXml
If (Not(IsComObjectCreated(hoXml))) Begin
Send CreateComObject of hoXml
End
Set ComTag Of hoXml To "soapenv:Envelope"
Get ComAddAttribute Of hoXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
Get ComAddAttribute Of hoXml "xmlns:sum" "https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" To iSuccess
Get ComAddAttribute Of hoXml "xmlns:sum1" "https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd" To iSuccess
Get ComAddAttribute Of hoXml "xmlns:xd" "http://www.w3.org/2000/09/xmldsig#" To iSuccess
Send ComUpdateChildContent To hoXml "soapenv:Header" ""
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:Cabecera|sum1:ObligadoEmision|sum1:NombreRazon" "XYZ STORE SL"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:Cabecera|sum1:ObligadoEmision|sum1:NIF" "B99999999"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:Cabecera|sum1:RemisionRequerimiento|sum1:RefRequerimiento" "3333333333"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:Cabecera|sum1:RemisionRequerimiento|sum1:FinRequerimiento" "S"
// This Id is URI in the XML digital signature Reference.
Get ComUpdateAttrAt Of hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta" True "Id" sRegistroAlta_id To iSuccess
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:IDVersion" "1.0"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:IDFactura|sum1:IDEmisorFactura" "89890001K"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:IDFactura|sum1:NumSerieFactura" "12345678-G66"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:IDFactura|sum1:FechaExpedicionFactura" "03-02-2025"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:NombreRazonEmisor" "certificado uno telematicas"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Subsanacion" "N"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:RechazoPrevio" "N"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:TipoFactura" "R3"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:TipoRectificativa" "I"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:FacturasRectificadas|sum1:IDFacturaRectificada|sum1:IDEmisorFactura" "89890001K"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:FacturasRectificadas|sum1:IDFacturaRectificada|sum1:NumSerieFactura" "12345600-G66"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:FacturasRectificadas|sum1:IDFacturaRectificada|sum1:FechaExpedicionFactura" "01-04-2024"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:FechaOperacion" "03-02-2025"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:DescripcionOperacion" "fecha entrega"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Destinatarios|sum1:IDDestinatario|sum1:NombreRazon" "certificado dos telematicas"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Destinatarios|sum1:IDDestinatario|sum1:NIF" "89890002E"
Move 0 To i
Set ComI Of hoXml To i
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:ClaveRegimen" 01
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CalificacionOperacion" "S1"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:TipoImpositivo" 4
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:BaseImponibleOimporteNoSujeto" 10
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CuotaRepercutida" "0.4"
Move (i + 1) To i
Set ComI Of hoXml To i
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:ClaveRegimen" 01
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CalificacionOperacion" "S1"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:TipoImpositivo" 21
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:BaseImponibleOimporteNoSujeto" 100
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CuotaRepercutida" 21
Move (i + 1) To i
Set ComI Of hoXml To i
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:ClaveRegimen" 05
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CalificacionOperacion" "S1"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:TipoImpositivo" 10
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:BaseImponibleOimporteNoSujeto" 100
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Desglose|sum1:DetalleDesglose[i]|sum1:CuotaRepercutida" 10
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:CuotaTotal" "41.4"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:ImporteTotal" "241.4"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Encadenamiento|sum1:RegistroAnterior|sum1:IDEmisorFactura" "89890001K"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Encadenamiento|sum1:RegistroAnterior|sum1:NumSerieFactura" "12345677-G33"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Encadenamiento|sum1:RegistroAnterior|sum1:FechaExpedicionFactura" "15-04-2024"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Encadenamiento|sum1:RegistroAnterior|sum1:Huella" "C9AF4AF1EF5EBBA700350DE3EEF12C2D355C56AC56F13DB2A25E0031BD2B7ED5"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:NombreRazon" "CERTIFICADO UNO TELEMATICAS"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:NIF" "89890001K"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:NombreSistemaInformatico" "NombreSistemaInformatico"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:IdSistemaInformatico" 77
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:Version" "1.0.03"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:NumeroInstalacion" 383
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:TipoUsoPosibleSoloVerifactu" "S"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:TipoUsoPosibleMultiOT" "N"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:SistemaInformatico|sum1:IndicadorMultiplesOT" "N"
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:FechaHoraHusoGenRegistro" "2025-02-03T14:30:00+01:00"
Send ComUpdateChildContentInt To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:TipoHuella" 01
Send ComUpdateChildContent To hoXml "soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta|sum1:Huella" "FF954378B64ED331A9B2366AD317D86E9DEC1716B12DD0ACCB172A6DC4C105AA"
// Generate an ID such as "xmldsig-90637596-e368-4bd0-bcf8-d9a7be617d9a"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbSigId
If (Not(IsComObjectCreated(hoSbSigId))) Begin
Send CreateComObject of hoSbSigId
End
Get ComAppend Of hoSbSigId "xmldsig-" To iSuccess
Get ComAppendUuid Of hoSbSigId True To iSuccess
// Generate an ID such as "xmldsig-90637596-e368-4bd0-bcf8-d9a7be617d9a-sigvalue"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbSigValueId
If (Not(IsComObjectCreated(hoSbSigValueId))) Begin
Send CreateComObject of hoSbSigValueId
End
Get pvComObject of hoSbSigId to vSbSigId
Get ComAppendSb Of hoSbSigValueId vSbSigId To iSuccess
Get ComAppend Of hoSbSigValueId "-sigvalue" To iSuccess
// Generate an ID such as "xmldsig-90637596-e368-4bd0-bcf8-d9a7be617d9a-signedprops"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbSignedPropsId
If (Not(IsComObjectCreated(hoSbSignedPropsId))) Begin
Send CreateComObject of hoSbSignedPropsId
End
Get pvComObject of hoSbSigId to vSbSigId
Get ComAppendSb Of hoSbSignedPropsId vSbSigId To iSuccess
Get ComAppend Of hoSbSignedPropsId "-signedprops" To iSuccess
// Generate an ID such as "xmldsig-90637596-e368-4bd0-bcf8-d9a7be617d9a-ref0"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbObjectRefId
If (Not(IsComObjectCreated(hoSbObjectRefId))) Begin
Send CreateComObject of hoSbObjectRefId
End
Get pvComObject of hoSbSigId to vSbSigId
Get ComAppendSb Of hoSbObjectRefId vSbSigId To iSuccess
Get ComAppend Of hoSbObjectRefId "-ref0" To iSuccess
Get Create (RefClass(cComChilkatXmlDSigGen)) To hoGen
If (Not(IsComObjectCreated(hoGen))) Begin
Send CreateComObject of hoGen
End
Set ComSigLocation Of hoGen To "soapenv:Envelope|soapenv:Body|sum:RegFactuSistemaFacturacion|sum:RegistroFactura|sum1:RegistroAlta"
Set ComSigLocationMod Of hoGen To 0
Get ComGetAsString Of hoSbSigId To sTemp1
Set ComSigId Of hoGen To sTemp1
Set ComSigNamespacePrefix Of hoGen To "ds"
Set ComSigNamespaceUri Of hoGen To "http://www.w3.org/2000/09/xmldsig#"
Get ComGetAsString Of hoSbSigValueId To sTemp1
Set ComSigValueId Of hoGen To sTemp1
Set ComSignedInfoCanonAlg Of hoGen To "C14N"
Set ComSignedInfoDigestMethod Of hoGen To "sha256"
// Create an Object to be added to the Signature.
Get Create (RefClass(cComChilkatXml)) To hoObject1
If (Not(IsComObjectCreated(hoObject1))) Begin
Send CreateComObject of hoObject1
End
Set ComTag Of hoObject1 To "xades:QualifyingProperties"
Get ComAddAttribute Of hoObject1 "xmlns:xades" "http://uri.etsi.org/01903/v1.3.2#" To iSuccess
Get ComAddAttribute Of hoObject1 "xmlns:xades141" "http://uri.etsi.org/01903/v1.4.1#" To iSuccess
// "#xmldsig-90637596-e368-4bd0-bcf8-d9a7be617d9a"
Get ComPrepend Of hoSbSigId "#" To iSuccess
Get ComGetAsString Of hoSbSigId To sTemp1
Get ComAddAttribute Of hoObject1 "Target" sTemp1 To iSuccess
Get ComGetAsString Of hoSbSignedPropsId To sTemp1
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties" True "Id" sTemp1 To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime" "TO BE GENERATED BY CHILKAT"
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod" True "Algorithm" "http://www.w3.org/2000/09/xmldsig#sha1" To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber" "TO BE GENERATED BY CHILKAT"
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[1]|xades:CertDigest|ds:DigestMethod" True "Algorithm" "http://www.w3.org/2000/09/xmldsig#sha1" To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[1]|xades:CertDigest|ds:DigestValue" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[1]|xades:IssuerSerial|ds:X509IssuerName" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[1]|xades:IssuerSerial|ds:X509SerialNumber" "TO BE GENERATED BY CHILKAT"
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[2]|xades:CertDigest|ds:DigestMethod" True "Algorithm" "http://www.w3.org/2000/09/xmldsig#sha1" To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[2]|xades:CertDigest|ds:DigestValue" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[2]|xades:IssuerSerial|ds:X509IssuerName" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert[2]|xades:IssuerSerial|ds:X509SerialNumber" "TO BE GENERATED BY CHILKAT"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier" "urn:oid:2.16.724.1.3.1.1.2.1.9"
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description" ""
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod" True "Algorithm" "http://www.w3.org/2000/09/xmldsig#sha1" To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue" "G7roucf600+f03r/o0bAOQ6WAs0="
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyQualifiers|xades:SigPolicyQualifier|xades:SPURI" "https://sede.administracion.gob.es/politica_de_firma_anexo_1.pdf"
Get ComPrepend Of hoSbObjectRefId "#" To iSuccess
Get ComGetAsString Of hoSbObjectRefId To sTemp1
Get ComUpdateAttrAt Of hoObject1 "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat" True "ObjectReference" sTemp1 To iSuccess
Send ComUpdateChildContent To hoObject1 "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType" "text/xml"
Get ComGetXml Of hoObject1 To sTemp1
Get ComAddObject Of hoGen "" sTemp1 "" "" To iSuccess
// -------- Reference 1 --------
// The URI for this Reference is the registroAlta_id
Get ComAddSameDocRef Of hoGen sRegistroAlta_id "sha256" "" "" "" To iSuccess
// Remove the "#"
Get ComRemoveCharsAt Of hoSbObjectRefId 0 1 To iSuccess
Get ComGetAsString Of hoSbObjectRefId To sTemp1
Get ComSetRefIdAttr Of hoGen sRegistroAlta_id sTemp1 To iSuccess
// -------- Reference 2 --------
Get ComGetAsString Of hoSbSignedPropsId To sTemp1
Get ComAddObjectRef Of hoGen sTemp1 "sha256" "C14N" "" "http://uri.etsi.org/01903#SignedProperties" To iSuccess
// Provide a certificate + private key. (PFX password is test123)
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadPfxFile Of hoCert "qa_data/pfx/cert_test123.pfx" "test123" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoCert to vCert
Get ComSetX509Cert Of hoGen vCert True To iSuccess
Set ComKeyInfoType Of hoGen To "X509Data+KeyValue"
Set ComX509Type Of hoGen To "Certificate"
// Load XML to be signed...
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbXml
If (Not(IsComObjectCreated(hoSbXml))) Begin
Send CreateComObject of hoSbXml
End
Get pvComObject of hoSbXml to vSbXml
Get ComGetXmlSb Of hoXml vSbXml To iSuccess
Set ComBehaviors Of hoGen To "IndentedSignature,Base64Cr13Entity"
// Sign the XML...
Get pvComObject of hoSbXml to vSbXml
Get ComCreateXmlDSigSb Of hoGen vSbXml To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoGen To sTemp1
Showln sTemp1
Procedure_Return
End
// -----------------------------------------------
// Save the signed XML to a file.
Get ComWriteFile Of hoSbXml "c:/temp/qa_output/signedSoapXml1.xml" "utf-8" False To iSuccess
Get ComGetAsString Of hoSbXml To sTemp1
Showln sTemp1
// ----------------------------------------
// Verify the signatures we just produced...
Get Create (RefClass(cComChilkatXmlDSig)) To hoVerifier
If (Not(IsComObjectCreated(hoVerifier))) Begin
Send CreateComObject of hoVerifier
End
Get pvComObject of hoSbXml to vSbXml
Get ComLoadSignatureSb Of hoVerifier vSbXml To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoVerifier To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumSignatures Of hoVerifier To iNumSigs
Move 0 To iVerifyIdx
While (iVerifyIdx < iNumSigs)
Set ComSelector Of hoVerifier To iVerifyIdx
Get ComVerifySignature Of hoVerifier True To iVerified
If (iVerified <> True) Begin
Get ComLastErrorText Of hoVerifier To sTemp1
Showln sTemp1
Procedure_Return
End
Move (iVerifyIdx + 1) To iVerifyIdx
Loop
Showln "All signatures were successfully verified."
End_Procedure