Xbase++
Xbase++
REST Auto Reconnect for Multiple Requests (dev.markitondemand.com)
See more REST Examples
Demonstrates how the autoReconnect argument to the Connect method is used.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oRest
LOCAL nBTls
LOCAL nPort
LOCAL nBAutoReconnect
LOCAL cResponseXml
LOCAL oXml
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oRest := CreateObject("Chilkat.Rest")
// This example demonstrates the usage of the autoReconnect argument to the Connect method.
// When autoReconnect is on, subsequent REST method calls will automatically re-connect
// if necessary, using the same information (domain/IP address, port number, and TLS).
nBTls := 0
nPort := 80
nBAutoReconnect := 1
nSuccess := oRest:Connect("dev.markitondemand.com", nPort, nBTls, nBAutoReconnect)
// Get a stock quote:
nSuccess := oRest:AddQueryParam("symbol", "AAPL")
cResponseXml := oRest:FullRequestNoBody("GET", "/MODApis/Api/v2/Quote")
IF (oRest:LastMethodSuccess != 1)
? oRest:LastErrorText
oRest:destroy()
RETURN
ENDIF
oXml := CreateObject("Chilkat.Xml")
nSuccess := oXml:LoadXml(cResponseXml)
? "AAPL LastPrice: " + oXml:GetChildContent("LastPrice")
// Get another stock quote. If a new HTTP connection is required,
// the REST object will automatically connect using the same parameters.
nSuccess := oRest:AddQueryParam("symbol", "AMZN")
cResponseXml := oRest:FullRequestNoBody("GET", "/MODApis/Api/v2/Quote")
IF (oRest:LastMethodSuccess != 1)
? oRest:LastErrorText
oRest:destroy()
oXml:destroy()
RETURN
ENDIF
nSuccess := oXml:LoadXml(cResponseXml)
? "AMZN LastPrice: " + oXml:GetChildContent("LastPrice")
oRest:destroy()
oXml:destroy()