Omnis Technical Note TNWS0005 September 2016
For Omnis Studio 8.0.1 or above*
by Rod Cooper, Omnis Engineering
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:
- 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:
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.