Invoking a service synchronously from outside of Rich UI

Service invocation outside of Rich UI is always synchronous, which means that the requester waits for a response from the service.
Here is the syntax of the service-invocation statement for service access from another service:
returnValueVariable = serviceName.operationName(argumentList) {timeout = milliseconds};
returnValueVariable
Name of a variable that receives the return value
serviceName
Name of a variable that is based on an Interface or Service part
operationName
Name of the Interface part function prototype.
argumentList
List of arguments, each of which is separated from the next by a comma

A change made to a parameter value in the service has no effect on the value of the argument variable that is provided in the service-invocation statement.

For details about the restrictions on parameters that are sent to a third-party REST service, see "Specifying parameters for service access in Rich UI."

milliseconds
The maximum valid number of milliseconds that elapse between when the EGL runtime code invokes a service and when the EGL runtime code receives a response. If more time elapses, the EGL runtime code throws a ServiceInvocationException.
To set a timeout:
  • Take into account a variety of factors, such as local network traffic, internet traffic, and server response time. Those factors mean that two invocations of the same service are likely to take a different amount of time under different conditions.
  • Consider the nature of your application. If your code is waiting for a credit approval, you might set a high timeout value to avoid charging the user twice. If your code is making a bid in an online auction bid, you might set a low timeout value so that the user can make an additional bid quickly.
  • Use timeout values that vary from one another by one or more seconds.

You can set a default value for milliseconds in the defaultServiceTimeout build descriptor option. The defaultServiceTimeout build descriptor option has no default value set, so if you do not specify a value for either defaultServiceTimeout or for milliseconds, the service call will not time out. For more information, see “defaultServiceTimeout.”

try blocks

Use a try block to test for an Exception record of type AnyException:

try 
   myString = myService.myOperation(1);
   onException (except AnyException)
   case 
      when (exp isa ServiceBindingException)
         ;
      when (exp isa ServiceInvocationException)
         ;
      otherwise
         ; 
   end
end
Errors might occur in these places:
  • In a service binding; that is, in how the service access is specified in your code. This error might involve a problem in the deployment descriptor.
  • In the communication of the requester with the service
  • In the service

A problem in a service binding results in a ServiceBindingException. Other problems result in a ServiceInvocationException or (less likely) a RuntimeException.


Feedback