Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Unicode C Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Unicode C) Create XAdES Facturae 3.2 Signed Invoice

See more XAdES Examples

Demonstrates how to create a factura electrónica XAdES digital signature for Gobierno de España

Note: This example requires Chilkat v9.5.0.92 or greater. Problems specific to XML signatures for FacturaE in Spain were fixed in v9.5.0.92.

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <C_CkXmlW.h>
#include <C_CkXmlDSigGenW.h>
#include <C_CkCertW.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    HCkXmlW xmlToSign;
    HCkXmlDSigGenW gen;
    BOOL success;
    HCkXmlW object1;
    HCkCertW cert;
    HCkStringBuilderW sbXml;

    // ----------------------------------------------------------------------
    // IMPORTANT: This generated example requires Chilkat v9.5.0.75 or later.
    // Contact support@chilkatsoft.com for a pre-release.
    // ----------------------------------------------------------------------

    // ---
    // The following source code can be generated from sample XML using the XML Signature Code Generator at chilkat.io
    // ---

    // IMPORTANT: This example requires Chilkat v9.5.0.92 or greater.  Problems specific to XML signatures for FacturaE in Spain were fixed in v9.5.0.92.

    // Create the XML to be signed...
    xmlToSign = CkXmlW_Create();
    CkXmlW_putTag(xmlToSign,L"fe:Facturae");
    CkXmlW_AddAttribute(xmlToSign,L"xmlns:ds",L"http://www.w3.org/2000/09/xmldsig#");
    CkXmlW_AddAttribute(xmlToSign,L"xmlns:fe",L"http://www.facturae.es/Facturae/2009/v3.2/Facturae");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|SchemaVersion",L"3.2");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Modality",L"I");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|InvoiceIssuerType",L"EM");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|BatchIdentifier",L"0000000000B2Emit-");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|InvoicesCount",L"1");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|TotalInvoicesAmount|TotalAmount",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|TotalOutstandingAmount|TotalAmount",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|TotalExecutableAmount|TotalAmount",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"FileHeader|Batch|InvoiceCurrencyCode",L"EUR");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|TaxIdentification|PersonTypeCode",L"J");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|TaxIdentification|ResidenceTypeCode",L"R");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|TaxIdentification|TaxIdentificationNumber",L"A82735122");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|CorporateName",L"Company Comp SA");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|TradeName",L"Comp");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|Book",L"1");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|RegisterOfCompaniesLocation",L"12AP22");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|Sheet",L"3");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|Folio",L"15");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|Section",L"2");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|Volume",L"12");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|RegistrationData|AdditionalRegistrationData",L"Sin datos");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|AddressInSpain|Address",L"C/ Mayour 33 15 E");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|AddressInSpain|PostCode",L"28001");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|AddressInSpain|Town",L"Argamasilla de Alba");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|AddressInSpain|Province",L"Ciudad Real");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|AddressInSpain|CountryCode",L"ESP");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|Telephone",L"917776665");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|TeleFax",L"917776666");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|WebAddress",L"www.facturae.es");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|ElectronicMail",L"facturae@mityc.es");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|ContactPersons",L"Fernando");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|CnoCnae",L"28000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|INETownCode",L"2134AAB");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|SellerParty|LegalEntity|ContactDetails|AdditionalContactDetails",L"Otros datos");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|TaxIdentification|PersonTypeCode",L"F");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|TaxIdentification|ResidenceTypeCode",L"E");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|TaxIdentification|TaxIdentificationNumber",L"0000000000B");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreCode",L"1");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|RoleTypeCode",L"02");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|Name",L"Ruth");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|FirstSurname",L"Mauripo");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Address",L"Armenia 1922");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|PostCodeAndTown",L"00000 Buenos Aires");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Province",L"Capital Federal");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|CountryCode",L"ARG");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreDescription",L"Centro principal de recepcion");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|Name",L"Juana");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|FirstSurname",L"Mauripo");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|OverseasAddress|Address",L"Juncal 1315");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|OverseasAddress|PostCodeAndTown",L"00000 Buenos Aires");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|OverseasAddress|Province",L"Capital Federal");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|OverseasAddress|CountryCode",L"ARG");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|ContactDetails|Telephone",L"00547775554");
    CkXmlW_UpdateChildContent(xmlToSign,L"Parties|BuyerParty|Individual|ContactDetails|TeleFax",L"00547775555");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceHeader|InvoiceNumber",L"2");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceHeader|InvoiceSeriesCode",L"Emit-");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceHeader|InvoiceDocumentType",L"FC");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceHeader|InvoiceClass",L"OO");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|IssueDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|OperationDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PostCode",L"00000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PlaceOfIssueDescription",L"Regalos");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|StartDate",L"2010-03-09");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|EndDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|InvoiceCurrencyCode",L"EUR");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|TaxCurrencyCode",L"EUR");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceIssueData|LanguageName",L"es");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|TaxTypeCode",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|TaxRate",L"16.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|TaxableBase|TotalAmount",L"26.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|TaxAmount|TotalAmount",L"4.16");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurcharge",L"1.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount",L"0.26");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax[1]|TaxTypeCode",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax[1]|TaxRate",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesOutputs|Tax[1]|TaxableBase|TotalAmount",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesWithheld|Tax|TaxTypeCode",L"05");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesWithheld|Tax|TaxRate",L"4.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesWithheld|Tax|TaxableBase|TotalAmount",L"26.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|TaxesWithheld|Tax|TaxAmount|TotalAmount",L"1.04");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalGrossAmount",L"59.75");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalGeneralDiscounts",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalGeneralSurcharges",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalGrossAmountBeforeTaxes",L"59.75");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalTaxOutputs",L"4.42");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalTaxesWithheld",L"1.04");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|InvoiceTotal",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalOutstandingAmount",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|InvoiceTotals|TotalExecutableAmount",L"63.13");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|IssuerContractReference",L"A9938281");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|IssuerContractDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|IssuerTransactionReference",L"A9938282");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|IssuerTransactionDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ReceiverContractReference",L"BBBH-38271");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ReceiverContractDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionReference",L"BBBH-38272");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|FileReference",L"000298172");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|FileDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|SequenceNumber",L"1.0");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteNumber",L"132413842");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteNumber",L"987673211");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteDate",L"2010-03-09");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ItemDescription",L"Flores");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|Quantity",L"1.0");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|UnitOfMeasure",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|UnitPriceWithoutTax",L"25.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|TotalCost",L"25.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountReason",L"Descuento");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountRate",L"5.0000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountAmount",L"1.250000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeReason",L"Cargo");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeAmount",L"10.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|GrossAmount",L"33.750000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxTypeCode",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxRate",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxableBase|TotalAmount",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxAmount|TotalAmount",L"0.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|AdditionalLineItemInformation",L"Contacto en Neuquen: Paulita");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventCode",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventReason",L"Concepto exento por el motivo aqu definido");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine|ArticleCode",L"142");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|IssuerContractDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|IssuerTransactionDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|ReceiverContractDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|ReceiverTransactionDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|FileDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|SequenceNumber",L"2.0");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|ItemDescription",L"Mate");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|Quantity",L"2.0");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|UnitOfMeasure",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|UnitPriceWithoutTax",L"13.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TotalCost",L"26.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|GrossAmount",L"26.000000");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxTypeCode",L"05");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxRate",L"4.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxableBase|TotalAmount",L"26.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxAmount|TotalAmount",L"1.04");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxTypeCode",L"01");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxRate",L"16.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxableBase|TotalAmount",L"26.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxAmount|TotalAmount",L"4.16");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurcharge",L"1.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount",L"0.26");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|Items|InvoiceLine[1]|ArticleCode",L"122");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|InstallmentDueDate",L"2010-03-10");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|InstallmentAmount",L"25.00");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|PaymentMeans",L"19");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|IBAN",L"4322 3432 22 1341234212");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BankCode",L"4322");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BranchCode",L"3432");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Address",L"Juncal 1423 8 Z");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|PostCodeAndTown",L"01115 Capital Federal");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Province",L"Buenos Aires");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|CountryCode",L"ARG");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|PaymentReconciliationReference",L"12223");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|IBAN",L"1234 4312 22 33212341212314");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BankCode",L"1234");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BranchCode",L"4312");
    CkXmlW_UpdateChildContent(xmlToSign,L"Invoices|Invoice|PaymentDetails|Installment|DebitReconciliationReference",L"12223");

    gen = CkXmlDSigGenW_Create();
    success = TRUE;

    CkXmlDSigGenW_putSigLocation(gen,L"fe:Facturae");
    CkXmlDSigGenW_putSigLocationMod(gen,0);
    CkXmlDSigGenW_putSigId(gen,L"Signature869123");
    CkXmlDSigGenW_AddSignatureNamespace(gen,L"etsi",L"http://uri.etsi.org/01903/v1.3.2#");
    CkXmlDSigGenW_putSigNamespacePrefix(gen,L"ds");
    CkXmlDSigGenW_putSigNamespaceUri(gen,L"http://www.w3.org/2000/09/xmldsig#");
    CkXmlDSigGenW_putSignedInfoId(gen,L"Signature-SignedInfo241096");
    CkXmlDSigGenW_putSignedInfoCanonAlg(gen,L"EXCL_C14N");
    CkXmlDSigGenW_putSignedInfoDigestMethod(gen,L"sha256");

    // Create an Object to be added to the Signature.
    object1 = CkXmlW_Create();
    CkXmlW_putTag(object1,L"xades:QualifyingProperties");
    CkXmlW_AddAttribute(object1,L"xmlns:xades",L"http://uri.etsi.org/01903/v1.3.2#");
    // The Id can be any unique string..
    CkXmlW_AddAttribute(object1,L"Id",L"QualifyingProperties-e01a8fee-1bee-4ff5-9570-3d57aa02f278");
    CkXmlW_AddAttribute(object1,L"Target",L"#Signature869123");
    CkXmlW_UpdateAttrAt(object1,L"xades:SignedProperties",TRUE,L"Id",L"Signature869123-SignedProperties787205");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime",L"TO BE GENERATED BY CHILKAT");
    // Note: It may be that http://www.w3.org/2001/04/xmlenc#sha256 is needed in the following line instead of http://www.w3.org/2000/09/xmldsig#sha1
    CkXmlW_UpdateAttrAt(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod",TRUE,L"Algorithm",L"http://www.w3.org/2000/09/xmldsig#sha1");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue",L"TO BE GENERATED BY CHILKAT");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName",L"TO BE GENERATED BY CHILKAT");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber",L"TO BE GENERATED BY CHILKAT");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier",L"http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description",L"Poltica de Firma FacturaE v3.1");
    CkXmlW_UpdateAttrAt(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod",TRUE,L"Algorithm",L"http://www.w3.org/2000/09/xmldsig#sha1");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue",L"Ohixl6upD6av8N7pEvDABhEL6hM=");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedSignatureProperties|xades:SignerRole|xades:ClaimedRoles|xades:ClaimedRole",L"emisor");
    CkXmlW_UpdateAttrAt(object1,L"xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat",TRUE,L"ObjectReference",L"#Reference-ID-670821");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description",L"Factura electrnica");
    CkXmlW_UpdateChildContent(object1,L"xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType",L"text/xml");

    CkXmlDSigGenW_AddObject(gen,L"Signature869123-Object629337",CkXmlW_getXml(object1),L"",L"");

    CkXmlDSigGenW_AddObjectRef(gen,L"Signature869123-SignedProperties787205",L"sha1",L"",L"",L"http://uri.etsi.org/01903#SignedProperties");
    CkXmlDSigGenW_SetRefIdAttr(gen,L"Signature869123-SignedProperties787205",L"SignedPropertiesID459347");

    CkXmlDSigGenW_putKeyInfoId(gen,L"Certificate1570061");
    CkXmlDSigGenW_AddSameDocRef(gen,L"Certificate1570061",L"sha1",L"",L"",L"");

    CkXmlDSigGenW_AddSameDocRef(gen,L"",L"sha1",L"",L"",L"");
    CkXmlDSigGenW_SetRefIdAttr(gen,L"",L"Reference-ID-670821");

    // Provide a certificate + private key. (PFX password is test123)
    cert = CkCertW_Create();
    success = CkCertW_LoadPfxFile(cert,L"qa_data/pfx/cert_test123.pfx",L"test123");
    if (success != TRUE) {
        wprintf(L"%s\n",CkCertW_lastErrorText(cert));
        CkXmlW_Dispose(xmlToSign);
        CkXmlDSigGenW_Dispose(gen);
        CkXmlW_Dispose(object1);
        CkCertW_Dispose(cert);
        return;
    }

    CkXmlDSigGenW_SetX509Cert(gen,cert,TRUE);
    CkXmlDSigGenW_putKeyInfoType(gen,L"X509Data+KeyValue");
    CkXmlDSigGenW_putX509Type(gen,L"Certificate");

    // Load XML to be signed...
    sbXml = CkStringBuilderW_Create();
    CkXmlW_GetXmlSb(xmlToSign,sbXml);

    CkXmlDSigGenW_putBehaviors(gen,L"CompactSignedXml");

    // Sign the XML...
    success = CkXmlDSigGenW_CreateXmlDSigSb(gen,sbXml);
    if (success != TRUE) {
        wprintf(L"%s\n",CkXmlDSigGenW_lastErrorText(gen));
        CkXmlW_Dispose(xmlToSign);
        CkXmlDSigGenW_Dispose(gen);
        CkXmlW_Dispose(object1);
        CkCertW_Dispose(cert);
        CkStringBuilderW_Dispose(sbXml);
        return;
    }

    // Save the signed XMl to a file.
    success = CkStringBuilderW_WriteFile(sbXml,L"qa_output/signedXml.xml",L"utf-8",FALSE);

    wprintf(L"%s\n",CkStringBuilderW_getAsString(sbXml));


    CkXmlW_Dispose(xmlToSign);
    CkXmlDSigGenW_Dispose(gen);
    CkXmlW_Dispose(object1);
    CkCertW_Dispose(cert);
    CkStringBuilderW_Dispose(sbXml);

    }

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.