Service access in Rich UI

Service access in an EGL Rich UI handler or library is always asynchronous: the requester continues running without waiting for a response from the service. The user can still interact with the user interface while the requester waits for the service to respond.

The following code accesses the implementation that is shown in “EGL support for SOA”:
myBindingVar IHttp?{@Resource{uri = "binding:myEntry"}};

call myService.myEcho("world")
     using myBindingVar
     returning to myCallBack
     onException myExceptionHandler;

The first statement accesses an instance of a binding that is created from the specified entry in an EGL deployment descriptor. The second statement uses that binding detail in an invocation.

After the invocation, the service does a task and, in most cases, responds to the EGL runtime code. The EGL runtime code then invokes a callback function. A callback function is a Rich UI function that you code and that you specify in the call statement that accesses the service. The invocation by the EGL runtime code is described as issuing a callback. If an error occurs during service access and you have specified an exception handler in the call statement, the EGL runtime code invokes the exception handler.

In the previous example, the myCallBack callback function (not shown) receives the text that is returned from a service and places it on the web page at run time.

Typically, the process for accessing services from Rich UI is as follows:
  1. Use a workbench tool to create an EGL Interface part that describes the service operations. For a given operation, the part identifies the return value and argument list.
  2. Create an access variable that is based on the Interface part.
  3. Use the variable in a call statement. The call statement includes the details that the EGL runtime code needs in order to issue a callback and specify an exception handler, which is invoked at run time if the invocation fails.

Rich UI proxy

To access a service, a Rich UI application uses the Rich UI proxy. The Rich UI proxy is runtime software that is installed with your code on an application server that is compliant with Java™ EE.

The EGL Rich UI proxy is runtime software that is installed with your Rich UI code, which runs on an application server that is compliant with Java EE. The proxy handles the communication between the application and any services that are accessed by the application:

The format of the body of the enclosing HTTP message is JavaScript™ Object Notation (JSON).

The Rich UI application uses the EGL Rich UI proxy to access every invoked service, even services that are on the same server.

Services that can be accessed from Rich UI

Your Rich UI application can access the following kinds of services:
  • A REST service, including an EGL Service type that is deployed as an EGL REST-RPC service.
  • An EGL Service type that is deployed as a dedicated service, which is available only to the Rich UI application. A dedicated service is local to the Rich UI proxy and runs in the application server that transmitted the Rich UI application.

    You can use the dedicated service to do tasks that other EGL-generated Java services can do, such as accessing a database. However, the dedicated service is not available to other code unless you redeploy it as a web service.