Results 1 to 5 of 5

Thread: Working with OData

  1. #1
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,730
    Blog Entries
    18

    Working with OData

    Lianja Cloud Server supports OData-compatible data access.

    The Server handles ODBC connections as well as HTTP requests using OData URIs. In the following article I will show you how to use Lianja Cloud Server with OData URIs that will allow you to perform CRUD (Create, Read, Update and Delete) operations on your data.

    Making OData requests from jQuery and/or the Lianja HTML5 Client in a Web App is extremely straightforward and simple.

    Unlike other OData implementations, Lianja Cloud Server OData services does not require any server-side configuration of web services.

    http://www.lianja.com/resources/blog...-cloud-server-

    You can use Lianja cloud server odata calls to perform CRUD operations on virtual tables too so this functionality is not limited to native Lianja data; MSSQL, MySQL, PostgreSQL, Oracle and others are all supported.

    Let me just emphasize again. Unlike other OData implementations, Lianja Cloud Server OData services does not require any server-side configuration of web services.
    Last edited by barrymavin; 2017-01-27 at 04:14.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,129
    Hi Barry,

    After successful playing with Southwind, I've tried with MS SQL and virtual table.
    I made ODBC (32 / windows authentification) and got 19820 records in vt_customers of database cloudlibtest and I see them in grid.

    Demo example_webvirtualtables works great too with this VT.

    I cant get it in Chrome:
    http://127.0.0.1/odata/cloudlibtest/vt_customers

    Error:
    The requested page was not found
    The requested URL /odata/cloudlibtest/vt_customers was not found on this server.
    http://127.0.0.1/odata/southwind/customers works as expected
    (the only thing I dont know how to open/use the result of $format=img)

    I have tried with wwwroot settings in Lianja SQL Server Manager:
    C:\lianja\sqlserver\wwwroot\ (from the blog screenshot)
    and with
    C:\lianja\cloudserver\tenants\public\wwwroot\
    no avail.

    Josip

  3. #3
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,713
    Hi Josip,

    Check the troubleshooter here: http://www.lianja.com/doc/index.php/...s#Test_Web_App

    That is for the example_webvirtualtables App, but will also apply to accessing the vt_customers vt via direct OData URIs.

    Regards,

    Yvonne

  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,129
    I can't get odata to work in Chrome with virtual table and MS SQL Server 2008 / ODBC DSN client 10.0

    I passed all troubleshooting points but nothing improved (deploying stuff is not applicable because it is not an app, but Chrome).

    The same happened if I use SQL Server authentication.

    I was expecting that if I can get vt_customers to be shown in the grid (Data ws) then everything is OK with my DSN, MS SQL Server connection and permissions.
    Also, if I can get http://127.0.0.1/odata/southwind/customers to work in Chrome, then all is OK with Cloud Server.
    That's why I am puzzled.

    Something bothers me: what wwwroot need to be set?
    In my Lianja Server Manager I initially found:
    C:\lianja\cloudserver\tenants\public\wwwroot\
    and in the blog it is
    C:\lianja\sqlserver\wwwroot\
    (have tried both. It doesn't matter for "odataing" southwind)

    I wonder when doubleclicking on vt_customers in Data ws, from where (wwwroot) I get the records?
    and from where in Chrome if I "odata" southwind or cloulibtest?

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,730
    Blog Entries
    18
    Using OData to query MSSQL is working fine for me.

    Name:  Screen Shot 2017-01-31 at 9.07.51 AM.jpg
Views: 527
Size:  170.7 KB

    The example shows how to use it with Lianja SQL Server.

    wwwroot should be set to C:\lianja\cloudserver\tenants\public\wwwroot\

    Remember also that you have the odata_create(), odata_read(), odata_update() and odata_delete() functions that can be used in both programs and rsp pages. These functions provide an OData abstraction above the target database SQL syntax. e.g. you can fetch MSSQL data using $limit (see below).

    Name:  Screen Shot 2017-01-31 at 10.01.45 AM.jpg
Views: 552
Size:  92.5 KB

    These examples were executed using the final release of Lianja 3.2 so try with that when it is available of download.

    With regards to your question about $format=img, if you select an image field from a table then it will be output as an IMG tag with embedded data encoding so that you can insert this into the DOM to fetch and display an image.

    Name:  Screen Shot 2017-01-31 at 10.13.25 AM.jpg
Views: 532
Size:  112.4 KB

    By specifying memo fields you can also perform CRUD operations on JSON data.

    Clearly there is a lot of power in this and it demonstrates how you can use Lianja Cloud Server to handle OData CRUD operations from other third party UI frameworks if that is a requirement. To use these OData functions on the client (no server side coding required) you should include the following files in your App:

    /library/jquery-1.10.2/jquery-1.10.2.min.js
    /library/LianjaWebFramework/LianjaCloudDataServices.js

    This provides core javascript client side functionality for working with the LIanja Cloud Server. It is not required with Lianja Apps as they have the full framework included.

    You can read and study the source code to see what functions are available in LianjaCloudDataServices.js

    I keep mentioning over and over but I will do so again. Lianja OData as implemented in Lianja Cloud Server does not require any server side coding or web services and it can be used to perform CRUD operations on all native Lianja databases and all major SQL databases i.e. MSSQL, PostGreSQL, MySQL, Oracle and others.



    Last edited by barrymavin; 2017-01-30 at 21:32.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us