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

 

 

 

(SQL Server) WIN Air Freight Login POST Request

Demonstrates the "login" POST method endpoint to obtain an initial authToken as a cookie. Each API request will return a fresh authToken cookie which must be passed back to WIN in the next API request.

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
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat HTTP API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Set the "Accept" header to tell the web server that we'll accept an XML response.
    EXEC sp_OASetProperty @http, 'Accept', 'application/xml'
    -- Tell Chilkat to cache any received cookies to files in a particular directory
    EXEC sp_OASetProperty @http, 'CookieDir', 'c:/qa_data/cookies'
    EXEC sp_OASetProperty @http, 'SaveCookies', 1

    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xml OUT

    EXEC sp_OASetProperty @xml, 'Tag', 'LogOnModel'
    EXEC sp_OAMethod @xml, 'NewChild2', NULL, 'UserName', 'win-air-freight-user@company.com'
    EXEC sp_OAMethod @xml, 'NewChild2', NULL, 'Password', 'win-air-freight-password'
    EXEC sp_OASetProperty @xml, 'EmitXmlDecl', 0

    DECLARE @resp int
    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @http, 'PText', @resp OUT, 'POST', 'http://integration.winwebconnect.com/api/v1/Login', @sTmp0, 'utf-8', 'application/xml', 0, 0
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @xml
        RETURN
      END

    DECLARE @xmlResponse int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xmlResponse OUT

    DECLARE @success int
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    EXEC sp_OAMethod @xmlResponse, 'LoadXml', @success OUT, @sTmp0

    -- See below for an example XML response body.

    PRINT 'Response Body:'
    EXEC sp_OAMethod @xmlResponse, 'GetXml', @sTmp0 OUT
    PRINT @sTmp0

    PRINT '---'


    PRINT 'Response Header:'
    EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
    PRINT @sTmp0

    -- An example resp header:
    -- 
    -- 	Cache-Control: no-cache
    -- 	Pragma: no-cache
    -- 	Content-Length: 1671
    -- 	Content-Type: application/xml; charset=utf-8
    -- 	Expires: -1
    -- 	Set-Cookie: authToken=1467EC8A5D2F1390F89F9DB65AAAAB5C709D1AE7275B72B6DDBDA44C54AE5D5C19648F76AAB12C9D9E2690F0DD69BE6E1C0F6D725C9392E99E1904A6B76D7852948C01A49E2FF20914092843C062778B91EE7497DDF4C1AC4117110E414195C9726E3467BD98094437044A8E94F1BCA1; path=/; HttpOnly
    -- 	Access-Control-Allow-Origin: http://integration.winwebconnect.com
    -- 	Date: Mon, 21 Nov 2016 21:29:57 GMT

    EXEC @hr = sp_OADestroy @resp


    PRINT 'Success.'

    -- An example XML response body:
    -- -----------------------------
    -- 	<?xml version="1.0" encoding="utf-8" ?>
    -- 	<AuthResponseDTO>
    -- 	    <LastLogin>2016-11-21T21:29:58.229986Z</LastLogin>
    -- 	    <UserDetails>
    -- 	        <ContactID>16528</ContactID>
    -- 	        <AgentID>96592</AgentID>
    -- 	        <FirstName>System</FirstName>
    -- 	        <LastName>User</LastName>
    -- 	        <Email>test@company.com</Email>
    -- 	        <JobTitle />
    -- 	        <ContactNumber />
    -- 	        <IsActivated>true</IsActivated>
    -- 	        <OperatedBy />
    -- 	        <AddressBookID />
    -- 	        <Permissions>integrationapi</Permissions>
    -- 	        <ContactType>Primary</ContactType>
    -- 	        <UCTReferer />
    -- 	        <UCTIsCaptcha>false</UCTIsCaptcha>
    -- 	        <UATReferer />
    -- 	        <UATIsCaptcha>false</UATIsCaptcha>
    -- 	        <Username>test@company.com</Username>
    -- 	    </UserDetails>
    -- 	    <AgentDetails>
    -- 	        <AgentID>96592</AgentID>
    -- 	        <AgentName>My Company</AgentName>
    -- 	        <AccountNumber />
    -- 	        <IATACode />
    -- 	        <Address1>P.O. Box 555</Address1>
    -- 	        <Address2 />
    -- 	        <Place />
    -- 	        <StateProvince>NC</StateProvince>
    -- 	        <City>
    -- 	            <Code>USBFO</Code>
    -- 	            <Name>Raleigh</Name>
    -- 	        </City>
    -- 	        <Country>
    -- 	            <Code>US</Code>
    -- 	            <Name>US - United States</Name>
    -- 	        </Country>
    -- 	        <ZipCode>28522</ZipCode>
    -- 	        <Email />
    -- 	        <Phone />
    -- 	        <Fax />
    -- 	        <IsEAirwayBill>false</IsEAirwayBill>
    -- 	        <EYProgram>false</EYProgram>
    -- 	        <WhiteLabelMobileApp>false</WhiteLabelMobileApp>
    -- 	        <Limits>
    -- 	            <UCTSearchesRemaining />
    -- 	            <UATSearchesRemaining />
    -- 	            <AgentID>96592</AgentID>
    -- 	        </Limits>
    -- 	        <Permissions>integrationapi</Permissions>
    -- 	    </AgentDetails>
    -- 	    <UserPreferences>
    -- 	        <AboutUs />
    -- 	        <MOTD />
    -- 	        <Language>en-US</Language>
    -- 	        <Currency>USD</Currency>
    -- 	        <UnitSystem>Metric</UnitSystem>
    -- 	        <TimeZone>
    -- 	            <TheID>450</TheID>
    -- 	            <KeyIdentifier>TimeZone</KeyIdentifier>
    -- 	            <KeyValue>GMT</KeyValue>
    -- 	            <KeyDescription>(GMT-11:00)UTC-11</KeyDescription>
    -- 	            <IsDefault>false</IsDefault>
    -- 	        </TimeZone>
    -- 	        <DateFormat>dd-MMM-yyyy</DateFormat>
    -- 	        <TimeFormat>h:mm t</TimeFormat>
    -- 	        <Controls />
    -- 	        <ContactEmail />
    -- 	    </UserPreferences>
    -- 	    <Version>
    -- 	        <APIVersion>3.4.0.0ah8</APIVersion>
    -- 	        <UIVersion>3.1</UIVersion>
    -- 	    </Version>
    -- 	    <NumNonMSDBContacts />
    -- 	</AuthResponseDTO>
    -- 

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @xmlResponse


END
GO

 

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