![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) palena.sii.cl getToken SOAP RequestDemonstrates how to call getToken SOAP request at palena.sii.cl Note: This example requires Chilkat v11.0.0 or greater.
llSuccess = .F. // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Create the XML to be signed... loXmlToSign = createobject("CkXml") loXmlToSign.Tag = "getToken" // This is the seed obtained from palena.sii.cl getSeed loXmlToSign.UpdateChildContent("item|Semilla","033878794660") loGen = createobject("CkXmlDSigGen") loGen.SigLocation = "getToken" loGen.SigLocationMod = 0 loGen.SigNamespacePrefix = "" loGen.SigNamespaceUri = "http://www.w3.org/2000/09/xmldsig#" loGen.SignedInfoCanonAlg = "EXCL_C14N" loGen.SignedInfoDigestMethod = "sha1" loGen.AddSameDocRef("","sha1","","","") // Provide a certificate + private key. (PFX password is test123) loCert = createobject("CkCert") llSuccess = loCert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123") if (llSuccess = .F.) then ? loCert.LastErrorText release loXmlToSign release loGen release loCert return endif loGen.SetX509Cert(loCert,.T.) loGen.KeyInfoType = "X509Data" loGen.X509Type = "Certificate" // Load XML to be signed... loSbXml = createobject("CkStringBuilder") loXmlToSign.EmitXmlDecl = .F. loXmlToSign.GetXmlSb(loSbXml) loGen.Behaviors = "IndentedSignature" // Sign the XML... llSuccess = loGen.CreateXmlDSigSb(loSbXml) if (llSuccess = .F.) then ? loGen.LastErrorText release loXmlToSign release loGen release loCert release loSbXml return endif // ----------------------------------------------- loHttp = createobject("CkHttp") loHttp.UncommonOptions = "AllowEmptyHeaders" loHttp.SetRequestHeader("SOAPAction","") // The endpoint for this soap service is: lcEndPoint = "https://palena.sii.cl/DTEWS/GetTokenFromSeed.jws" // Send the following SOAP XML // <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="http://DefaultNamespace"> // <soapenv:Header/> // <soapenv:Body> // <def:getToken soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> // <pszXml>SIGNED_XML_GOES_HERE</pszXml> // </def:getToken> // </soapenv:Body> // </soapenv:Envelope> loXml = createobject("CkXml") loXml.Tag = "soapenv:Envelope" loXml.AddAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance") loXml.AddAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema") loXml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/") loXml.AddAttribute("xmlns:def","http://DefaultNamespace") loXml.UpdateChildContent("soapenv:Header","") loXml.UpdateAttrAt("soapenv:Body|def:getToken",.T.,"soapenv:encodingStyle","http://schemas.xmlsoap.org/soap/encoding/") loXml.UpdateChildContent("soapenv:Body|def:getToken|pszXml","SIGNED_XML_GOES_HERE") // We must replace the "SIGNED_XML_GOES_HERE" with the exact contents of the signed XML to ensure the signed XML is not modified in any way. loSbSoapXml = createobject("CkStringBuilder") loSbSoapXml.Append(loXml.GetXml()) lnNumReplaced = loSbXml.Replace("&","&") lnNumReplaced = loSbXml.Replace(">",">") lnNumReplaced = loSbXml.Replace("<","<") lnNumReplaced = loSbXml.Replace('"',""") lnNumReplaced = loSbSoapXml.Replace("SIGNED_XML_GOES_HERE",loSbXml.GetAsString()) lcXmlStr = loSbSoapXml.GetAsString() loResp = createobject("CkHttpResponse") llSuccess = loHttp.HttpStr("POST",lcEndPoint,lcXmlStr,"utf-8","text/xml",loResp) if (llSuccess = .F.) then ? loHttp.LastErrorText release loXmlToSign release loGen release loCert release loSbXml release loHttp release loXml release loSbSoapXml release loResp return endif lnResponseStatusCode = loResp.StatusCode ? "Response Status Code: " + str(lnResponseStatusCode) // You may examine the exact HTTP header sent with the POST like this: ? "LastHeader:" ? loHttp.LastHeader // Examine the XML returned by the web service: ? "XML Response:" loXmlResp = createobject("CkXml") loXmlResp.LoadXml(loResp.BodyStr) ? loXmlResp.GetXml() // Use this online tool to generate parsing code from response XML: // Generate Parsing Code from XML release loXmlToSign release loGen release loCert release loSbXml release loHttp release loXml release loSbSoapXml release loResp release loXmlResp |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.