Download presentation
Presentation is loading. Please wait.
1
Rich UI Inter-Program Communication
Course Rich UI Inter-Program Communication Units: Creating an end-to-end RESTful Service
2
Create an End-to-End EGL Web Service using REST only
From your EGLWeb project: Create a new Service part in the \EGLSource\services\ folder, named: RUIRestServices (remember to start Tomcat) Be sure to check: Create as WEB (REST) service Here is the service code You can either code this from scratch, or copy/paste this function from the Slide ***Notes When you’ve saved and all syntax errors are cleaned up: From Project Explorer, Generate the entire EGLWeb project This action will also deploy your EGL Rest Service to Tomcat service RUIRestServices function addNumbers(number1 int in, number2 int in) returns(int) return (number1 + number2); end
3
Consume an End-to-End EGL Web Service using REST only --- Client
In the Project Explorer, right-mouse click your service and then click on: EGL Services Extract Interface… In the wizard, select the EGLSource folder in the RUI Project i.e. EGLRichUI Create a new RUI Handler called RUIRestServiceTest in the mysamples package Copy the RUI code from the Slide ***Notes All EGL REST services use this pattern: /restservices/<ServiceName> Note: If you are seeing errors, make sure to Generate your service project Run your service on Tomcat Verify that Tomcat is using port 8080 Package mySamples; Import services.IRUIRestServices; Handler RUIRestServiceTest type RUIhandler { onConstructionFunction = start} function start() svc IRUIRestServices { base URI = “ }}; call svc.addNumbers(3, 4) returning to showResult onException serviceLib.serviceExceptionHandler; end function showResult(result int in) writeStdout(“Your Numbers added together using a REST Service is : “ + result); End
4
Create an End-to-End EGLWeb Service using REST only
After copy\pasting the REST Service code into the editor, press CTRL + S to Save, then select the preview tab : Package mySamples; Import services.IRUIRestServices; Handler RUIRestServiceTest type RUIhandler { initialUI = [Box,Box1], onConstructionFunction = start} Box1 com.ibm.egl.rui.widgets.Box{padding=9, Children = [TextLabel, TextLabel1] }; TextLabel1 com.ibm.egl.rui.widgets.TextLabel{width=“25”}; TextLabel com.ibm.egl.rui.widgets.TextLabel{width=“350”}; Box com.ibm.egl.rui.widgets.Box{padding=9, children = [RESTImage], columns = 1}; RESTImage com.ibm.egl.rui.widgets.Image{src = “images/reasonglobe.jpg”}; function start() svc IRUIRestServices { baseURI = “ }}; call svc.addNumbers(3, 4) returning to showResult onException serviceLib.serviceExceptionHandler; end function showResult(result int in) writeStdout( “Your Numbers added together using a REST Service is : “ + result); End Note : You will have 2 projects: A service project that is deployed on TOMCAT A RUI project that invokes the service using an interface
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.