You can use dynamic binding to access or update binding details in response to conditions at run time.
Dynamic binding is not available for access of a dedicated service from a Rich UI handler or a library.
<restBinding baseURI="http://myHostName" enableGeneration="true" name="MyEnglishBinding" preserveRequestHeaders="false"/> <restBinding baseURI="http://myHostName02" enableGeneration="true" name="MyFrenchBinding" preserveRequestHeaders="false"/>
The first variation might return a value in English while the second a value in French.
You might create and bind two variables, one for each of these entries. Alternatively, you can create one variable that is based on the Interface part that corresponds to the service. Then, you can use the SysLib.getResource() system function to bind the variable to one or the other deployed service:
myService MyInterfacePart?;
myService = SysLib.getResource("MyEnglishBinding");In this case, the myService variable is now bound to the entry named MyBinding. If you avoid specifying an argument in the function call, the argument value is the name of the variable to which the function is assigning a value.
myContent string = myService.myEcho("world");
The value of myContent is “Hello, world!”
myTranslator = SysLib.getResource("MyFrenchBinding");
myContent = myService.myEcho("world");
The value of myContent is “Bonjour, monde!”
myService IMyService; myBinding HttpRest{@Resource}; myBinding.request.encoding = Encoding.json; myService = servicelib.completeBind(myService, myBinding);
myService IMyService?;
The Interface part typically includes a URI template annotation, which is a set of lower-level URI qualifiers that are resolved at run time. The resolved template might be /GetWeatherByZipCode?zipCode=27709.
myBinding.request.encoding = Encoding.json;
myService = servicelib.completeBind(myService, myBinding);
myBinding HttpRest{@Resource}; // or myBinding HttpRest = SysLib.getResource("myBinding");
In either case, the EGL runtime code accesses the deployment-descriptor entry named myBinding.
http HttpRest = new HttpRest{ restType = eglx.rest.ServiceType.TrueRest, uri = "www.example.com/myproject/restservices/weather_service};