Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(VBScript) SOAP WS-Security Username AuthenticationDemonstrates creating SOAP XML for WS-Security Username Authentication. The client user name and password are encapsulated in a WS-Security <wsse:UsernameToken>.
Dim fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") 'Create a Unicode (utf-16) output text file. Set outFile = fso.CreateTextFile("output.txt", True, True) ' 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: ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Xml") set xml = CreateObject("Chilkat.Xml") xml.Tag = "soap:Envelope" success = xml.AddAttribute("xmlns:soap","http://schemas.xmlsoap.org/soap/envelope/") xml.UpdateChildContent "soap:Header","" success = xml.UpdateAttrAt("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 ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.CkDateTime") set dt = CreateObject("Chilkat.CkDateTime") success = dt.SetFromCurrentSystemTime() bLocal = 0 created = dt.GetAsTimestamp(bLocal) ' Now build each UsernameToken block: ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Xml") set wsse1 = CreateObject("Chilkat.Xml") wsse1.Tag = "wsse:Security" success = wsse1.AddAttribute("xmlns:wsse","http://schemas.xmlsoap.org/ws/2003/06/secext") success = wsse1.UpdateAttrAt("wsse:UsernameToken",1,"wsu:Id","sample") success = wsse1.UpdateAttrAt("wsse:UsernameToken",1,"xmlns:wsu","http://schemas.xmlsoap.org/ws/2003/06/utility") wsse1.UpdateChildContent "wsse:UsernameToken|wsse:Username","sample" success = wsse1.UpdateAttrAt("wsse:UsernameToken|wsse:Password",1,"Type","wsse:PasswordText") wsse1.UpdateChildContent "wsse:UsernameToken|wsse:Password","oracle" wsse1.UpdateChildContent "wsse:UsernameToken|wsu:Created",created ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Xml") set wsse2 = CreateObject("Chilkat.Xml") wsse2.Tag = "wsse:Security" success = wsse2.AddAttribute("soap:actor","oracle") success = wsse2.AddAttribute("xmlns:wsse","http://schemas.xmlsoap.org/ws/2003/06/secext") success = wsse2.UpdateAttrAt("wsse:UsernameToken",1,"wsu:Id","oracle") success = wsse2.UpdateAttrAt("wsse:UsernameToken",1,"xmlns:wsu","http://schemas.xmlsoap.org/ws/2003/06/utility") wsse2.UpdateChildContent "wsse:UsernameToken|wsse:Username","oracle" success = wsse2.UpdateAttrAt("wsse:UsernameToken|wsse:Password",1,"Type","wsse:PasswordText") wsse2.UpdateChildContent "wsse:UsernameToken|wsse:Password","oracle" wsse2.UpdateChildContent "wsse:UsernameToken|wsu:Created",created ' Insert the UsernameToken blocks: ' xHeader is a Chilkat.Xml Set xHeader = xml.GetChildWithTag("soap:Header") success = xHeader.AddChildTree(wsse1) success = xHeader.AddChildTree(wsse2) ' Show the XML: outFile.WriteLine(xml.GetXml()) outFile.Close |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.