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

 

 

 

(SQL Server) Send DocuSign XML Request

Demonstrates how to send a DocuSign XML request.

Important:This example requires Chillkat v9.5.0.75 or greater.

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 @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @req int
    -- Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @req, 'HttpVerb', 'POST'

    -- Replace "12999999" with your own account number. (12999999 is a ficticious account number)
    EXEC sp_OASetProperty @req, 'Path', '/restapi/v2/accounts/12999999/envelopes'

    EXEC sp_OAMethod @req, 'AddHeader', NULL, 'Accept', 'application/xml'

    -- Don't worry about the boundary string.  Chilkat will automatically generate one and include it.
    EXEC sp_OASetProperty @req, 'ContentType', 'multipart/form-data'

    DECLARE @xmlCred int
    -- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xmlCred OUT

    EXEC sp_OASetProperty @xmlCred, 'Tag', 'DocuSignCredentials'
    EXEC sp_OAMethod @xmlCred, 'UpdateChildContent', NULL, 'Username', 'YOUR_DOCUSIGN_USERNAME'
    EXEC sp_OAMethod @xmlCred, 'UpdateChildContent', NULL, 'Password', 'YOUR_DOCUSIGN_PASSWORD'
    EXEC sp_OAMethod @xmlCred, 'UpdateChildContent', NULL, 'IntegratorKey', 'ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd'
    EXEC sp_OASetProperty @xmlCred, 'EmitXmlDecl', 0
    EXEC sp_OASetProperty @xmlCred, 'EmitCompact', 1
    EXEC sp_OAMethod @xmlCred, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @req, 'AddHeader', NULL, 'X-DocuSign-Authentication', @sTmp0

    -- Don't worry about Host or Content-Length headers, Chilkat automatically adds them...

    -- Build the XML for the 1st body part..
    DECLARE @xml int
    -- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT

    EXEC sp_OASetProperty @xml, 'Tag', 'envelopeDefinition'
    DECLARE @success int
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns', 'http://www.docusign.com/restapi'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'emailSubject', 'Signature Request: Test Test:001019:033611'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'status', 'sent'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'documents|document|documentId', '1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'documents|document|name', '001019_TestTest_RetailDeals_163357'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|hostEmail', 'admin@chilkatsoft.com'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|hostName', 'Chilkat Admin'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|signerName', 'Test  Test'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|recipientId', '1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|routingOrder', '1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|signerEmail', 'test@tyest.com'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString', '\SDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString', '\OSDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString', '\OPSSDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue', '0.7'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString', '\PSSDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue', '0.7'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString', '\IDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString', '\OIDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString', '\OPSIDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue', '0.5'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString', '\PSIDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue', '0.5'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|hostEmail', 'admin@chilkatsoft.com'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|hostName', 'Chilkat Admin'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|signerName', 'Dealer Representative'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|recipientId', '2'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|routingOrder', '2'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString', '\DSDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString', '\DOSDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString', '\DIDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional', 'False'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent', 'True'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString', '\DOIDP'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional', 'True'
    EXEC sp_OASetProperty @xml, 'EmitXmlDecl', 0

    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    PRINT @sTmp0

    EXEC sp_OASetProperty @xml, 'EmitCompact', 1

    -- IMPORTANT: This example requires Chilkat v9.5.0.75 or greater.
    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @req, 'AddStringForUpload2', @success OUT, '', '', @sTmp0, 'utf-8', 'application/xml'
    EXEC sp_OAMethod @req, 'AddFileForUpload2', @success OUT, '', 'qa_data/pdf/signatureForm.pdf', 'application/pdf'
    EXEC sp_OAMethod @req, 'AddSubHeader', @success OUT, 1, 'Content-Disposition', 'file; filename="signatureForm.pdf";documentid=1'

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT

    EXEC sp_OASetProperty @http, 'SessionLogFilename', 'qa_output/log.txt'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, 'na2.docusign.net', 443, 1, @req
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @req
        EXEC @hr = sp_OADestroy @xmlCred
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    IF @iTmp0 <> 201
      BEGIN
        EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
        PRINT @sTmp0

        EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
        PRINT 'Response status code: ' + @iTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @req
        EXEC @hr = sp_OADestroy @xmlCred
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    -- Examine the response..
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    EXEC sp_OAMethod @xml, 'LoadXml', @success OUT, @sTmp0
    DECLARE @envelopeId nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetChildContent', @envelopeId OUT, 'envelopeId'

    PRINT 'envelopeId = ' + @envelopeId
    DECLARE @status nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetChildContent', @status OUT, 'status'

    PRINT 'status = ' + @status
    DECLARE @statusDateTime nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetChildContent', @statusDateTime OUT, 'statusDateTime'

    PRINT 'statusDateTime = ' + @statusDateTime
    DECLARE @uri nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetChildContent', @uri OUT, 'uri'

    PRINT 'uri = ' + @uri

    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @req
    EXEC @hr = sp_OADestroy @xmlCred
    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @http


END
GO

 

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