If the purpose of a resource binding is service access, the definition is called a service binding. The main detail is in one of three categories:
Although you can run the deployed service during an EGL debugging session, the EGL debugger does not step into the service.
A workspace URI is useful only at development time, and an internal Test Server enables you to debug the code. The Test Server is described here: EGL test server.
myService MyServiceType {@DedicatedService};
At this writing, you can bind to a REST or EGL REST-RPC service. The distinctions among the service types are explained here: Service-oriented architecture (SOA) for EGL developers (http://www.eclipse.org/edt/papers/topics/egl_soa_overview.html).
For details on defining a service binding in the EGL deployment descriptor, see Adding a REST binding to the EGL deployment descriptor.
If you are defining a workspace binding, you must also deploy the Service type. For details, see Adding web-service deployment details to the EGL deployment descriptor.
myService MyInterfaceType?;
/* that declaration could have included
a Resource annotation, as shown here:
myService MyInterfaceType?
{ @Resource {uri="binding:MyGermanBinding"} }; */
if ( ... )
myService = SysLib.getResource("binding:MyEnglishBinding");
else
myService = SysLib.getResource("binding:MyFrenchBinding");
end
/* here, you can access the service operations of
one or the other service, assuming that the two
have similar interfaces. */
myService MyServiceType?;
http HttpRest{@Resource{uri="binding:myService"}};
http.request.encoding = encoding.json;
call myService.myFunction() using http returning to myCallBackFunction
onException myExceptionHandler;
The declaration references an Interface type that typically includes one or more uriTemplate annotation fields, each of which is a set of lower-level URI qualifiers that are resolved at run time. A resolved template might be this: /GetWeatherByZipCode?zipCode=27709
That object provides a higher-level URI such as http://www.example.com/myproject/restservices/weather_service.
In this case, the object contains details that are retrieved from a service binding in the EGL deployment descriptor. If you do not specify a uri annotation field, the name of the service binding is assumed to be the name of the variable. In the example, the value of the annotation field defaults to "binding:http".
For details on the HttpRest object, see the help topic named "eglx.http package."
myService IMyService?;
http HttpRest = new HttpRest{
restType = eglx.rest.ServiceType.TrueRest,
uri = "www.example.com/myproject/restservices/weather_service"};
myBinding.request.encoding = Encoding.json;
call myService.myFunction() using http returning to myCallBackFunction
onException myExceptionHandler;
For details on the HttpRest object, see the help topic named "eglx.http package."