Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

SQL Server Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(SQL Server) SOAP WS-Security Username Authentication

Demonstrates creating SOAP XML for WS-Security Username Authentication. The client user name and password are encapsulated in a WS-Security <wsse:UsernameToken>.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    --  Generate this XML with the code that follows:

    --  	<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    --  	 <soap:Header>
    --  	  <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
    --  	   <wsse:UsernameToken wsu:Id="sample"
    --  	       xmlns:wsu="http://schemas.xmlsoap.org/ws/2003/06/utility">
    --  	    <wsse:Username>sample</wsse:Username>
    --  	    <wsse:Password Type="wsse:PasswordText">oracle</wsse:Password>
    --  	    <wsu:Created>2004-05-19T08:44:51Z</wsu:Created>
    --  	   </wsse:UsernameToken>
    --  	  </wsse:Security>
    --  	  <wsse:Security soap:actor="oracle"
    --  	      xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
    --  	   <wsse:UsernameToken wsu:Id="oracle"
    --  	       xmlns:wsu="http://schemas.xmlsoap.org/ws/2003/06/utility">
    --  	    <wsse:Username>myUsername</wsse:Username>
    --  	    <wsse:Password Type="wsse:PasswordText">myPassword</wsse:Password>
    --  	    <wsu:Created>2004-05-19T08:46:04Z</wsu:Created>
    --  	   </wsse:UsernameToken>
    --  	  </wsse:Security>
    --  	 </soap:Header>
    --  	  <soap:Body>
    --  	   <getHello xmlns="http://www.oracle.com"/>
    --  	  </soap:Body>
    --  	</soap:Envelope>
    -- 

    --  First build the outer housing:
    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xml OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @xml, 'Tag', 'soap:Envelope'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:soap', 'http://schemas.xmlsoap.org/soap/envelope/'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soap:Body|getHello', 1, 'xmlns', 'http://www.oracle.com'

    --  Get the current date/time in a string with this format: 2004-05-19T08:46:04Z
    DECLARE @dt int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.CkDateTime', @dt OUT

    EXEC sp_OAMethod @dt, 'SetFromCurrentSystemTime', @success OUT
    DECLARE @bLocal int
    SELECT @bLocal = 0
    DECLARE @created nvarchar(4000)
    EXEC sp_OAMethod @dt, 'GetAsTimestamp', @created OUT, @bLocal

    --  Now build each UsernameToken block:
    DECLARE @wsse1 int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @wsse1 OUT

    EXEC sp_OASetProperty @wsse1, 'Tag', 'wsse:Security'
    EXEC sp_OAMethod @wsse1, 'AddAttribute', @success OUT, 'xmlns:wsse', 'http://schemas.xmlsoap.org/ws/2003/06/secext'
    EXEC sp_OAMethod @wsse1, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken', 1, 'wsu:Id', 'sample'
    EXEC sp_OAMethod @wsse1, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken', 1, 'xmlns:wsu', 'http://schemas.xmlsoap.org/ws/2003/06/utility'
    EXEC sp_OAMethod @wsse1, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsse:Username', 'sample'
    EXEC sp_OAMethod @wsse1, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken|wsse:Password', 1, 'Type', 'wsse:PasswordText'
    EXEC sp_OAMethod @wsse1, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsse:Password', 'oracle'
    EXEC sp_OAMethod @wsse1, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsu:Created', @created

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

    EXEC sp_OASetProperty @wsse2, 'Tag', 'wsse:Security'
    EXEC sp_OAMethod @wsse2, 'AddAttribute', @success OUT, 'soap:actor', 'oracle'
    EXEC sp_OAMethod @wsse2, 'AddAttribute', @success OUT, 'xmlns:wsse', 'http://schemas.xmlsoap.org/ws/2003/06/secext'
    EXEC sp_OAMethod @wsse2, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken', 1, 'wsu:Id', 'oracle'
    EXEC sp_OAMethod @wsse2, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken', 1, 'xmlns:wsu', 'http://schemas.xmlsoap.org/ws/2003/06/utility'
    EXEC sp_OAMethod @wsse2, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsse:Username', 'oracle'
    EXEC sp_OAMethod @wsse2, 'UpdateAttrAt', @success OUT, 'wsse:UsernameToken|wsse:Password', 1, 'Type', 'wsse:PasswordText'
    EXEC sp_OAMethod @wsse2, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsse:Password', 'oracle'
    EXEC sp_OAMethod @wsse2, 'UpdateChildContent', NULL, 'wsse:UsernameToken|wsu:Created', @created

    --  Insert the UsernameToken blocks:
    DECLARE @xHeader int
    EXEC sp_OAMethod @xml, 'GetChildWithTag', @xHeader OUT, 'soap:Header'
    EXEC sp_OAMethod @xHeader, 'AddChildTree', @success OUT, @wsse1
    EXEC sp_OAMethod @xHeader, 'AddChildTree', @success OUT, @wsse2
    EXEC @hr = sp_OADestroy @xHeader

    --  Show the XML:
    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    PRINT @sTmp0

    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @dt
    EXEC @hr = sp_OADestroy @wsse1
    EXEC @hr = sp_OADestroy @wsse2


END
GO

 

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