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

SQL Server 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
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

 

 

 

(SQL Server) 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 ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

// Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
//
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    -- ----------------------------------------------------------------------
    -- 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...
    DECLARE @xmlToSign int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xmlToSign OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

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

    DECLARE @gen int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.XmlDSigGen', @gen OUT

    DECLARE @success int
    SELECT @success = 1

    EXEC sp_OASetProperty @gen, 'SigLocation', 'fe:Facturae'
    EXEC sp_OASetProperty @gen, 'SigLocationMod', 0
    EXEC sp_OASetProperty @gen, 'SigId', 'Signature869123'
    EXEC sp_OAMethod @gen, 'AddSignatureNamespace', @success OUT, 'etsi', 'http://uri.etsi.org/01903/v1.3.2#'
    EXEC sp_OASetProperty @gen, 'SigNamespacePrefix', 'ds'
    EXEC sp_OASetProperty @gen, 'SigNamespaceUri', 'http://www.w3.org/2000/09/xmldsig#'
    EXEC sp_OASetProperty @gen, 'SignedInfoId', 'Signature-SignedInfo241096'
    EXEC sp_OASetProperty @gen, 'SignedInfoCanonAlg', 'EXCL_C14N'
    EXEC sp_OASetProperty @gen, 'SignedInfoDigestMethod', 'sha256'

    -- Create an Object to be added to the Signature.
    DECLARE @object1 int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @object1 OUT

    EXEC sp_OASetProperty @object1, 'Tag', 'xades:QualifyingProperties'
    EXEC sp_OAMethod @object1, 'AddAttribute', @success OUT, 'xmlns:xades', 'http://uri.etsi.org/01903/v1.3.2#'
    -- The Id can be any unique string..
    EXEC sp_OAMethod @object1, 'AddAttribute', @success OUT, 'Id', 'QualifyingProperties-e01a8fee-1bee-4ff5-9570-3d57aa02f278'
    EXEC sp_OAMethod @object1, 'AddAttribute', @success OUT, 'Target', '#Signature869123'
    EXEC sp_OAMethod @object1, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties', 1, 'Id', 'Signature869123-SignedProperties787205'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime', '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
    EXEC sp_OAMethod @object1, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod', 1, 'Algorithm', 'http://www.w3.org/2000/09/xmldsig#sha1'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier', 'http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description', 'Poltica de Firma FacturaE v3.1'
    EXEC sp_OAMethod @object1, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod', 1, 'Algorithm', 'http://www.w3.org/2000/09/xmldsig#sha1'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue', 'Ohixl6upD6av8N7pEvDABhEL6hM='
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignerRole|xades:ClaimedRoles|xades:ClaimedRole', 'emisor'
    EXEC sp_OAMethod @object1, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat', 1, 'ObjectReference', '#Reference-ID-670821'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description', 'Factura electrnica'
    EXEC sp_OAMethod @object1, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType', 'text/xml'

    EXEC sp_OAMethod @object1, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @gen, 'AddObject', @success OUT, 'Signature869123-Object629337', @sTmp0, '', ''

    EXEC sp_OAMethod @gen, 'AddObjectRef', @success OUT, 'Signature869123-SignedProperties787205', 'sha1', '', '', 'http://uri.etsi.org/01903#SignedProperties'
    EXEC sp_OAMethod @gen, 'SetRefIdAttr', @success OUT, 'Signature869123-SignedProperties787205', 'SignedPropertiesID459347'

    EXEC sp_OASetProperty @gen, 'KeyInfoId', 'Certificate1570061'
    EXEC sp_OAMethod @gen, 'AddSameDocRef', @success OUT, 'Certificate1570061', 'sha1', '', '', ''

    EXEC sp_OAMethod @gen, 'AddSameDocRef', @success OUT, '', 'sha1', '', '', ''
    EXEC sp_OAMethod @gen, 'SetRefIdAttr', @success OUT, '', 'Reference-ID-670821'

    -- Provide a certificate + private key. (PFX password is test123)
    DECLARE @cert int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Cert', @cert OUT

    EXEC sp_OAMethod @cert, 'LoadPfxFile', @success OUT, 'qa_data/pfx/cert_test123.pfx', 'test123'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @xmlToSign
        EXEC @hr = sp_OADestroy @gen
        EXEC @hr = sp_OADestroy @object1
        EXEC @hr = sp_OADestroy @cert
        RETURN
      END
    EXEC sp_OAMethod @gen, 'SetX509Cert', @success OUT, @cert, 1
    EXEC sp_OASetProperty @gen, 'KeyInfoType', 'X509Data+KeyValue'
    EXEC sp_OASetProperty @gen, 'X509Type', 'Certificate'

    -- Load XML to be signed...
    DECLARE @sbXml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbXml OUT

    EXEC sp_OAMethod @xmlToSign, 'GetXmlSb', @success OUT, @sbXml

    EXEC sp_OASetProperty @gen, 'Behaviors', 'CompactSignedXml'

    -- Sign the XML...
    EXEC sp_OAMethod @gen, 'CreateXmlDSigSb', @success OUT, @sbXml
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @gen, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @xmlToSign
        EXEC @hr = sp_OADestroy @gen
        EXEC @hr = sp_OADestroy @object1
        EXEC @hr = sp_OADestroy @cert
        EXEC @hr = sp_OADestroy @sbXml
        RETURN
      END

    -- Save the signed XMl to a file.
    EXEC sp_OAMethod @sbXml, 'WriteFile', @success OUT, 'qa_output/signedXml.xml', 'utf-8', 0

    EXEC sp_OAMethod @sbXml, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    EXEC @hr = sp_OADestroy @xmlToSign
    EXEC @hr = sp_OADestroy @gen
    EXEC @hr = sp_OADestroy @object1
    EXEC @hr = sp_OADestroy @cert
    EXEC @hr = sp_OADestroy @sbXml


END
GO

 

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