Omnis Technical Note TNWS0005 September 2016
For Omnis Studio 8.1.2 or above
by Rod Cooper, Omnis Engineering
There is an example library to accompany this tech note which you can download from GitHub: https://github.com/OmnisStudio/Omnis-HTTPPush (requires Studio 8.1.2 or above)
(or download this archive: httppush.zip requires Studio 8.0.1 or above)
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:
For Omnis Studio 8.1.2 or above (download from here)
- A Web Services Plugin serial number is not required since it is included with the Pro version of Omnis Studio.
- The Java JRE or SDK is no longer required since the library uses the CURL based OW3 HTTP worker object.
For Omnis Studio 8.0.x (using the zip archive)
- This library only works with Omnis Studio 8.0.1 or above since it uses icons in the ‘studio’ iconset in 8.0.1.
- Web Services Plugin serial number (available with ODPP).
- 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:
When you start Omnis, you can check the Trace Log (from the Tools menu) to see if the JVM has loaded correctly.
For all versions, you need to 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.
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.