Xbase++
Xbase++
palena.sii.cl getSeed SOAP Request
See more SII Chile Examples
Demonstrates how to call getSeed SOAP request at palena.sii.clChilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL nResponseStatusCode
LOCAL cEndPoint
LOCAL oXml
LOCAL oResp
LOCAL oXmlResp
LOCAL cEmbeddedXml
LOCAL oXml2
LOCAL cSeed
nSuccess := 0
oHttp := CreateObject("Chilkat.Http")
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp:UncommonOptions := "AllowEmptyHeaders"
oHttp:SetRequestHeader("SOAPAction", "")
// The endpoint for this soap service is:
cEndPoint := "https://palena.sii.cl/DTEWS/CrSeed.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:getSeed soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
// </soapenv:Body>
// </soapenv:Envelope>
oXml := CreateObject("Chilkat.Xml")
oXml:Tag := "soapenv:Envelope"
oXml:AddAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
oXml:AddAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema")
oXml:AddAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
oXml:AddAttribute("xmlns:def", "http://DefaultNamespace")
oXml:UpdateChildContent("soapenv:Header", "")
oXml:UpdateAttrAt("soapenv:Body|def:getSeed", 1, "soapenv:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/")
oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpStr("POST", cEndPoint, oXml:GetXml(), "utf-8", "text/xml", oResp)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oXml:destroy()
oResp:destroy()
RETURN
ENDIF
nResponseStatusCode := oResp:StatusCode
? "Response Status Code: " + Str(nResponseStatusCode)
// You may examine the exact HTTP header sent with the POST like this:
? "LastHeader:"
? oHttp:LastHeader
// Examine the XML returned by the web service:
? "XML Response:"
oXmlResp := CreateObject("Chilkat.Xml")
oXmlResp:LoadXml(oResp:BodyStr)
? oXmlResp:GetXml()
// Use this online tool to generate parsing code from response XML:
// Generate Parsing Code from XML
// The response is:
// <?xml version="1.0" encoding="UTF-8"?>
// <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
// <soapenv:Body>
// <ns1:getSeedResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://DefaultNamespace">
// <ns1:getSeedReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?><SII:RESPUESTA xmlns:SII="http://www.sii.cl/XMLSchema"><SII:RESP_BODY><SEMILLA>039159253918</SEMILLA></SII:RESP_BODY><SII:RESP_HDR><ESTADO>00</ESTADO></SII:RESP_HDR></SII:RESPUESTA></ns1:getSeedReturn>
// </ns1:getSeedResponse>
// </soapenv:Body>
// </soapenv:Envelope>
// Get the XML contained in the getSeedReturn element:
cEmbeddedXml := oXmlResp:GetChildContent("soapenv:Body|ns1:getSeedResponse|ns1:getSeedReturn")
? cEmbeddedXml
// The embedded XML is:
// <?xml version="1.0" encoding="UTF-8"?>
// <SII:RESPUESTA xmlns:SII="http://www.sii.cl/XMLSchema">
// <SII:RESP_BODY>
// <SEMILLA>039159397998</SEMILLA>
// </SII:RESP_BODY>
// <SII:RESP_HDR>
// <ESTADO>00</ESTADO>
// </SII:RESP_HDR>
// </SII:RESPUESTA>
// Get the seed:
oXml2 := CreateObject("Chilkat.Xml")
oXml2:LoadXml(cEmbeddedXml)
cSeed := oXml2:GetChildContent("SII:RESP_BODY|SEMILLA")
? "seed = " + cSeed
// --------------------------------------------------------------------------------
// Also see Chilkat's Online WSDL Code Generator
// to generate code and SOAP Request and Response XML for each operation in a WSDL.
// --------------------------------------------------------------------------------
oHttp:destroy()
oXml:destroy()
oResp:destroy()
oXmlResp:destroy()
oXml2:destroy()