Web Integration

From Lianjapedia
Jump to: navigation, search

WebViews

The WebView Section and the WebView Gadget provide the ability to render content generated by any URL and integrate this in with a Lianja App.

Use Macros in the URL to fetch contextual data content.

Lianja.showDialogPanel("CUSTOMER LOCATION", 
    "lib:/showdialog_map.rsp?address={customers.address}
                +{customers.city}+{customers.country}", 500);

getUrl() and postUrl()

You can use the GETURL() built-in function to talk with HTTP web servers and fetch data provided by web services.

filename = geturl("http://www.myserver.com/getsomepage.rsp?name=smith&month=10", 30, array(), "myfilename.json")
if len(filename) = 0
    // no data was returned
endif

You can use the POSTURL() built-in function to send an HTTP POST request to the specified URI.

// send a soap request
responsefile = posturl("http://www.myserver.com/somewebservice.aspx", ;
                           30, ;
                           array("type" => "Content-Type: application/soap+xml", "host" => "Host: localhost"), ;
                           "requestdata.xml","response.xml")
 
// submit a form
response = posturl("http://www.myserver.com/someformsubmission.rsp", ;
                           30, ;                              
                           array("type" => "Content-Type: application/x-www-form-urlencoded"), ;
                           "name=barry&product=lianja")                                         
if len(response) = 0    
    // no data was returned
endif

NetworkRequest

The NetworkRequest class in the Lianja Framework provides support for http, https and ftp reading and writing files and other data such as making OData requests.

It supports uploading and downloading of files with (optional) authenticated requests.

It can be used by any of the supported scripting languages; Visual FoxPro, PHP, Python or JavaScript.

If the async property is set to true, then you can subclass it and define an event handler called finished(data as character) that is passed the data received or the name of the filename containing the data when the request completes. If async is false then the operation is performed synchronously.

When using it in async mode the progressChanged(currentvalue as numeric, totalsize as numeric) event handler is called allowing you to provide progress feedback to the user during the request.

Additionally, in async mode you can call oRequest.isFinished() to determine if the request has completed.

You can verify that you have a valid network connections using oRequest.networkAccessible() and check for errors using oRequest.errorNumber and oRequest.errorString

oRequest = createObject("networkrequest")
oRequest.async = .f.
oRequest.username = "yourname"
oRequest.password = "yourpassword"
oRequest.setHeader("name", "value")
oRequest.setHeader("name2", "value")
oRequest.getFile("http://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.getFile("https://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.getFile("ftp://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.putFile("http://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.putFile("https://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.putFile("ftp://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.postFile("http://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.postFile("https://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
oRequest.postFile("ftp://www.anywhere.com/filename.xxx?arg=value&arg2=value", filename)
m_string = oRequest.getData("http://www.anywhere.com/filename.xxx?arg=value&arg2=value")
oRequest.putData("http://www.anywhere.com/filename.xxx?arg=value&arg2=value", "send this to the server")
oRequest.postData("http://www.anywhere.com/filename.xxx?arg=value&arg2=value", "send this to the server")

You can use this class very effectively when working with OData services in the Cloud.

Cloud ODBC Data Access

Using the ODBC drivers from https://www.devart.com/odbc/#cloud you can connect to the most popular cloud resources directly via HTTP.

The Devart ODBC Drivers provide high-performance and feature-rich connectivity solutions for ODBC-based applications to access the most popular databases directly from Windows, MacOS, Linux, both 32-bit and 64-bit. Drivers fully support standard ODBC API functions and data types, multiple server data types and features.

Use these ODBC drivers seamlessly in Lianja with Virtual Tables.

The easiest way to test ODBC connectivity is to use the following commands in the console workspace.

use dummy connstr "odbc-connection-string" as select * from tablename 
list

Using Virtual Tables with Local Stored Procedures

When using any of the above methods for retrieving cloud based data you can combine these with Virtual Table Local Stored Procedures and fully integrate external data seamlessly.