Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
ETrade
Egypt ITIDA
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
IntakeQ
Jira
Lightspeed
MYOB
Magento

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yousign
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Visual FoxPro) 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

LOCAL lnSuccess
LOCAL loXmlToSign
LOCAL loGen
LOCAL loCert
LOCAL loSbXml
LOCAL loHttp
LOCAL lnResponseStatusCode
LOCAL lcEndPoint
LOCAL loXml
LOCAL loSbSoapXml
LOCAL lnNumReplaced
LOCAL loResp
LOCAL loXmlResp

* 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('Chilkat_9_5_0.Xml')
loXmlToSign.Tag = "getToken"
* This is the seed obtained from palena.sii.cl getSeed
loXmlToSign.UpdateChildContent("item|Semilla","033878794660")

loGen = CreateObject('Chilkat_9_5_0.XmlDSigGen')

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('Chilkat_9_5_0.Cert')
lnSuccess = loCert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
IF (lnSuccess <> 1) THEN
    ? loCert.LastErrorText
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    CANCEL
ENDIF

loGen.SetX509Cert(loCert,1)

loGen.KeyInfoType = "X509Data"
loGen.X509Type = "Certificate"

* Load XML to be signed...
loSbXml = CreateObject('Chilkat_9_5_0.StringBuilder')
loXmlToSign.EmitXmlDecl = 0
loXmlToSign.GetXmlSb(loSbXml)

loGen.Behaviors = "IndentedSignature"

* Sign the XML...
lnSuccess = loGen.CreateXmlDSigSb(loSbXml)
IF (lnSuccess <> 1) THEN
    ? loGen.LastErrorText
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    RELEASE loSbXml
    CANCEL
ENDIF

* -----------------------------------------------

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

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

* 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('Chilkat_9_5_0.Xml')
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",1,"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('Chilkat_9_5_0.StringBuilder')
loSbSoapXml.Append(loXml.GetXml())
lnNumReplaced = loSbXml.Replace("&","&amp;")
lnNumReplaced = loSbXml.Replace(">","&gt;")
lnNumReplaced = loSbXml.Replace("<","&lt;")
lnNumReplaced = loSbXml.Replace('"',"&quot;")
lnNumReplaced = loSbSoapXml.Replace("SIGNED_XML_GOES_HERE",loSbXml.GetAsString())

loResp = loHttp.PostXml(lcEndPoint,loSbSoapXml.GetAsString(),"utf-8")
IF (loHttp.LastMethodSuccess <> 1) THEN
    ? loHttp.LastErrorText
    ? "LastHeader:"
    ? loHttp.LastHeader
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    RELEASE loSbXml
    RELEASE loHttp
    RELEASE loXml
    RELEASE loSbSoapXml
    CANCEL
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('Chilkat_9_5_0.Xml')
loXmlResp.LoadXml(loResp.BodyStr)
? loXmlResp.GetXml()

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

RELEASE loResp

RELEASE loXmlToSign
RELEASE loGen
RELEASE loCert
RELEASE loSbXml
RELEASE loHttp
RELEASE loXml
RELEASE loSbSoapXml
RELEASE loXmlResp


 

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