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

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

 

 

 

(DataFlex) 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

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoXml
    Boolean iSuccess
    Handle hoDt
    Boolean iBLocal
    String sCreated
    Variant vWsse1
    Handle hoWsse1
    Variant vWsse2
    Handle hoWsse2
    Variant vXHeader
    Handle hoXHeader
    String sTemp1

    // 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:
    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "soap:Envelope"
    Get ComAddAttribute Of hoXml "xmlns:soap" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
    Send ComUpdateChildContent To hoXml "soap:Header" ""
    Get ComUpdateAttrAt Of hoXml "soap:Body|getHello" True "xmlns" "http://www.oracle.com" To iSuccess

    // Get the current date/time in a string with this format: 2004-05-19T08:46:04Z
    Get Create (RefClass(cComCkDateTime)) To hoDt
    If (Not(IsComObjectCreated(hoDt))) Begin
        Send CreateComObject of hoDt
    End
    Get ComSetFromCurrentSystemTime Of hoDt To iSuccess
    Move False To iBLocal
    Get ComGetAsTimestamp Of hoDt iBLocal To sCreated

    // Now build each UsernameToken block:
    Get Create (RefClass(cComChilkatXml)) To hoWsse1
    If (Not(IsComObjectCreated(hoWsse1))) Begin
        Send CreateComObject of hoWsse1
    End
    Set ComTag Of hoWsse1 To "wsse:Security"
    Get ComAddAttribute Of hoWsse1 "xmlns:wsse" "http://schemas.xmlsoap.org/ws/2003/06/secext" To iSuccess
    Get ComUpdateAttrAt Of hoWsse1 "wsse:UsernameToken" True "wsu:Id" "sample" To iSuccess
    Get ComUpdateAttrAt Of hoWsse1 "wsse:UsernameToken" True "xmlns:wsu" "http://schemas.xmlsoap.org/ws/2003/06/utility" To iSuccess
    Send ComUpdateChildContent To hoWsse1 "wsse:UsernameToken|wsse:Username" "sample"
    Get ComUpdateAttrAt Of hoWsse1 "wsse:UsernameToken|wsse:Password" True "Type" "wsse:PasswordText" To iSuccess
    Send ComUpdateChildContent To hoWsse1 "wsse:UsernameToken|wsse:Password" "oracle"
    Send ComUpdateChildContent To hoWsse1 "wsse:UsernameToken|wsu:Created" sCreated

    Get Create (RefClass(cComChilkatXml)) To hoWsse2
    If (Not(IsComObjectCreated(hoWsse2))) Begin
        Send CreateComObject of hoWsse2
    End
    Set ComTag Of hoWsse2 To "wsse:Security"
    Get ComAddAttribute Of hoWsse2 "soap:actor" "oracle" To iSuccess
    Get ComAddAttribute Of hoWsse2 "xmlns:wsse" "http://schemas.xmlsoap.org/ws/2003/06/secext" To iSuccess
    Get ComUpdateAttrAt Of hoWsse2 "wsse:UsernameToken" True "wsu:Id" "oracle" To iSuccess
    Get ComUpdateAttrAt Of hoWsse2 "wsse:UsernameToken" True "xmlns:wsu" "http://schemas.xmlsoap.org/ws/2003/06/utility" To iSuccess
    Send ComUpdateChildContent To hoWsse2 "wsse:UsernameToken|wsse:Username" "oracle"
    Get ComUpdateAttrAt Of hoWsse2 "wsse:UsernameToken|wsse:Password" True "Type" "wsse:PasswordText" To iSuccess
    Send ComUpdateChildContent To hoWsse2 "wsse:UsernameToken|wsse:Password" "oracle"
    Send ComUpdateChildContent To hoWsse2 "wsse:UsernameToken|wsu:Created" sCreated

    // Insert the UsernameToken blocks:
    Get ComGetChildWithTag Of hoXml "soap:Header" To vXHeader
    If (IsComObject(vXHeader)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoXHeader
        Set pvComObject Of hoXHeader To vXHeader
    End
    Get pvComObject of hoWsse1 to vWsse1
    Get ComAddChildTree Of hoXHeader vWsse1 To iSuccess
    Get pvComObject of hoWsse2 to vWsse2
    Get ComAddChildTree Of hoXHeader vWsse2 To iSuccess
    Send Destroy of hoXHeader

    // Show the XML:
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1


End_Procedure

 

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