Omnis Technical Note TNWS0005 September 2016

Restful Web Services HTTP JavaScript Push Example

For Omnis Studio 8.0.1 or above*
by Rod Cooper, Omnis Engineering


This tech note describes how to push data returned from an Omnis RESTful Web Service to the JavaScript Client using the example library HTTPpush.lbs provided:

The library contains both RESTful web service server classes in a folder named 'Restful Service', together with classes for the web server in the root allowing it to be used using either of the following methods:

  1. As a single standalone library where the development copy of Omnis Studio acts as both the RESTful web service server and the JavaScript web server. Although not necessarily how the servers would eventually be deployed, but useful for demonstrating and investigating the methodology used.
  2. Using two copies of Omnis Studio and two copies of the library where one acts as the RESTful web service and the other as the JavaScript web server. These can be accessed directly or alternatively via a web server such as IIS using the RESTful and web server plugins (e.g. omnisrestisapi.dll and omnisapi.dll) as described in tech note tnjs0003.jsp.


  • Omnis Studio 8.0.1 or above (download from here); this version is required for the example library since it uses icons in the ‘studio’ iconset in 8.0.1.
  • Web Services Plugin serial number (available with ODPP).
  • Set the Omnis Serverport; to do this click on ‘Omnis Studio’, then Prefs in the Studio Browser and set $serverport in the Property Manager to 7000.
  • Install the Java JRE or SDK from the Java/Oracle website, and then set the appropriate environment variable OMNISJVM or OMNISJVM64, or update the “jvm” entry in Omnis configuration file ‘config.json’ in the Studio folder, by adding the location of the JVM file, which on Windows will be something like:
    "java": {
    "jvm":"C:\\Program Files\\Java\\jdk1.8.0_91\\jre\\bin\\server\\jvm.dll",
    "resetClassCacheOnStartup": false
    When you start Omnis, you can check the Trace Log (from the Tools menu) to see if the JVM has loaded correctly.

RESTful Web Service

Open the HTTPpush library and look in the ‘Restful Server’ folder. The remote task rtImages provides the RESTful web service and its $restfulapiname property is set to 'images' with the following URIs:

  • /Imagelist which returns a list of image filenames.
  • /Imagedata which returns the image data for a single image name.
  • /imagedata_multiple which returns image data for multiple images
  • /serverlog which returns a list of previous requests.

Push Remote Form - jsImages

The remote form jsImages establishes a push connection to the Omnis Server in $constuct via Do $cinst.$clientcommand("openpush",row()).

On testing the remote form a default URI based on your IP Address and Server Port setting is shown ready for using as described using method 1 above. (If you haven’t set your serverport, set via the Prefs hyperlink visible when the Omnis Studio node is selected in the Studio Browser, restart Omnis and re-test the form.)

Pressing Get Image List calls the RESTful web service via the HTPP client worker to obtain the list of image names and pushes them to the client using the remote form $pushdata method in $completed. Similarly Get Image and Get Selected pushes image data retuned from the web service to the client.

On each call to the RESTful web service the http Response returned together with last URI called is displayed.

Push Remote Form - jsServerLog

A second remote form example jsServerLog uses a timer worker object to push a list of the RESTful web server requests to the client, open in another browser tab simultaneously with jsImages and press Start Timer to watch the requests as they come in.