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
(PowerBuilder) 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>.
integer li_rc oleobject loo_Xml oleobject loo_Dt integer li_BLocal string ls_Created oleobject loo_Wsse1 oleobject loo_Wsse2 oleobject loo_XHeader // 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: loo_Xml = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml") if li_rc < 0 then destroy loo_Xml MessageBox("Error","Connecting to COM object failed") return end if loo_Xml.Tag = "soap:Envelope" loo_Xml.AddAttribute("xmlns:soap","http://schemas.xmlsoap.org/soap/envelope/") loo_Xml.UpdateChildContent("soap:Header","") loo_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 loo_Dt = create oleobject // Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime") loo_Dt.SetFromCurrentSystemTime() li_BLocal = 0 ls_Created = loo_Dt.GetAsTimestamp(li_BLocal) // Now build each UsernameToken block: loo_Wsse1 = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Wsse1.ConnectToNewObject("Chilkat.Xml") loo_Wsse1.Tag = "wsse:Security" loo_Wsse1.AddAttribute("xmlns:wsse","http://schemas.xmlsoap.org/ws/2003/06/secext") loo_Wsse1.UpdateAttrAt("wsse:UsernameToken",1,"wsu:Id","sample") loo_Wsse1.UpdateAttrAt("wsse:UsernameToken",1,"xmlns:wsu","http://schemas.xmlsoap.org/ws/2003/06/utility") loo_Wsse1.UpdateChildContent("wsse:UsernameToken|wsse:Username","sample") loo_Wsse1.UpdateAttrAt("wsse:UsernameToken|wsse:Password",1,"Type","wsse:PasswordText") loo_Wsse1.UpdateChildContent("wsse:UsernameToken|wsse:Password","oracle") loo_Wsse1.UpdateChildContent("wsse:UsernameToken|wsu:Created",ls_Created) loo_Wsse2 = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Wsse2.ConnectToNewObject("Chilkat.Xml") loo_Wsse2.Tag = "wsse:Security" loo_Wsse2.AddAttribute("soap:actor","oracle") loo_Wsse2.AddAttribute("xmlns:wsse","http://schemas.xmlsoap.org/ws/2003/06/secext") loo_Wsse2.UpdateAttrAt("wsse:UsernameToken",1,"wsu:Id","oracle") loo_Wsse2.UpdateAttrAt("wsse:UsernameToken",1,"xmlns:wsu","http://schemas.xmlsoap.org/ws/2003/06/utility") loo_Wsse2.UpdateChildContent("wsse:UsernameToken|wsse:Username","oracle") loo_Wsse2.UpdateAttrAt("wsse:UsernameToken|wsse:Password",1,"Type","wsse:PasswordText") loo_Wsse2.UpdateChildContent("wsse:UsernameToken|wsse:Password","oracle") loo_Wsse2.UpdateChildContent("wsse:UsernameToken|wsu:Created",ls_Created) // Insert the UsernameToken blocks: loo_XHeader = loo_Xml.GetChildWithTag("soap:Header") loo_XHeader.AddChildTree(loo_Wsse1) loo_XHeader.AddChildTree(loo_Wsse2) destroy loo_XHeader // Show the XML: Write-Debug loo_Xml.GetXml() destroy loo_Xml destroy loo_Dt destroy loo_Wsse1 destroy loo_Wsse2 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.