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

PowerBuilder Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PowerBuilder) palena.sii.cl getToken SOAP Request

Demonstrates how to call getToken SOAP request at palena.sii.cl

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
integer li_Success
oleobject loo_XmlToSign
oleobject loo_Gen
oleobject loo_Cert
oleobject loo_SbXml
oleobject loo_Http
integer li_ResponseStatusCode
string ls_EndPoint
oleobject loo_Xml
oleobject loo_SbSoapXml
integer li_NumReplaced
oleobject loo_Resp
oleobject loo_XmlResp

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// Create the XML to be signed...
loo_XmlToSign = create oleobject
li_rc = loo_XmlToSign.ConnectToNewObject("Chilkat_9_5_0.Xml")
if li_rc < 0 then
    destroy loo_XmlToSign
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_XmlToSign.Tag = "getToken"
// This is the seed obtained from palena.sii.cl getSeed
loo_XmlToSign.UpdateChildContent("item|Semilla","033878794660")

loo_Gen = create oleobject
li_rc = loo_Gen.ConnectToNewObject("Chilkat_9_5_0.XmlDSigGen")

loo_Gen.SigLocation = "getToken"
loo_Gen.SigLocationMod = 0
loo_Gen.SigNamespacePrefix = ""
loo_Gen.SigNamespaceUri = "http://www.w3.org/2000/09/xmldsig#"
loo_Gen.SignedInfoCanonAlg = "EXCL_C14N"
loo_Gen.SignedInfoDigestMethod = "sha1"

loo_Gen.AddSameDocRef("","sha1","","","")

// Provide a certificate + private key. (PFX password is test123)
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat_9_5_0.Cert")

li_Success = loo_Cert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
if li_Success <> 1 then
    Write-Debug loo_Cert.LastErrorText
    destroy loo_XmlToSign
    destroy loo_Gen
    destroy loo_Cert
    return
end if

loo_Gen.SetX509Cert(loo_Cert,1)

loo_Gen.KeyInfoType = "X509Data"
loo_Gen.X509Type = "Certificate"

// Load XML to be signed...
loo_SbXml = create oleobject
li_rc = loo_SbXml.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_XmlToSign.EmitXmlDecl = 0
loo_XmlToSign.GetXmlSb(loo_SbXml)

loo_Gen.Behaviors = "IndentedSignature"

// Sign the XML...
li_Success = loo_Gen.CreateXmlDSigSb(loo_SbXml)
if li_Success <> 1 then
    Write-Debug loo_Gen.LastErrorText
    destroy loo_XmlToSign
    destroy loo_Gen
    destroy loo_Cert
    destroy loo_SbXml
    return
end if

// -----------------------------------------------

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")

loo_Http.UncommonOptions = "AllowEmptyHeaders"
loo_Http.SetRequestHeader("SOAPAction","")

loo_Http.SetRequestHeader("Content-Type","text/xml; charset=utf-8")

// The endpoint for this soap service is:
ls_EndPoint = "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>

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat_9_5_0.Xml")

loo_Xml.Tag = "soapenv:Envelope"
loo_Xml.AddAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")
loo_Xml.AddAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema")
loo_Xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
loo_Xml.AddAttribute("xmlns:def","http://DefaultNamespace")
loo_Xml.UpdateChildContent("soapenv:Header","")
loo_Xml.UpdateAttrAt("soapenv:Body|def:getToken",1,"soapenv:encodingStyle","http://schemas.xmlsoap.org/soap/encoding/")
loo_Xml.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.
loo_SbSoapXml = create oleobject
li_rc = loo_SbSoapXml.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_SbSoapXml.Append(loo_Xml.GetXml())
li_NumReplaced = loo_SbXml.Replace("&","&amp;")
li_NumReplaced = loo_SbXml.Replace(">","&gt;")
li_NumReplaced = loo_SbXml.Replace("<","&lt;")
li_NumReplaced = loo_SbXml.Replace("\"","&quot;")
li_NumReplaced = loo_SbSoapXml.Replace("SIGNED_XML_GOES_HERE",loo_SbXml.GetAsString())

loo_Resp = loo_Http.PostXml(ls_EndPoint,loo_SbSoapXml.GetAsString(),"utf-8")
if loo_Http.LastMethodSuccess <> 1 then
    Write-Debug loo_Http.LastErrorText
    Write-Debug "LastHeader:"
    Write-Debug loo_Http.LastHeader
    destroy loo_XmlToSign
    destroy loo_Gen
    destroy loo_Cert
    destroy loo_SbXml
    destroy loo_Http
    destroy loo_Xml
    destroy loo_SbSoapXml
    return
end if

li_ResponseStatusCode = loo_Resp.StatusCode

Write-Debug "Response Status Code: " + string(li_ResponseStatusCode)

// You may examine the exact HTTP header sent with the POST like this:
Write-Debug "LastHeader:"
Write-Debug loo_Http.LastHeader

// Examine the XML returned by the web service:
Write-Debug "XML Response:"
loo_XmlResp = create oleobject
li_rc = loo_XmlResp.ConnectToNewObject("Chilkat_9_5_0.Xml")

loo_XmlResp.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_XmlResp.GetXml()

// Use this online tool to generate parsing code from response XML: 
// Generate Parsing Code from XML

destroy loo_Resp


destroy loo_XmlToSign
destroy loo_Gen
destroy loo_Cert
destroy loo_SbXml
destroy loo_Http
destroy loo_Xml
destroy loo_SbSoapXml
destroy loo_XmlResp

 

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