In EGL, you can use the following Interface part to access a third-party REST service:
interface IRest function invokeGet(reqURL string in) returns(string) {@getRest {uriTemplate="{reqURL}"}}; function invokePost(reqURL string in, representation string in) returns(string) {@postRest {uriTemplate="{reqURL}"}}; function invokePut(reqURL string in, representation string in) returns(string) {@putRest {uriTemplate="{reqURL}"}}; function invokeDelete(reqURL string in, representation string in) returns(string) {@deleteRest {uriTemplate="{reqURL}"}}; end
By using this Interface part as is, you do not have to write one. However, you write the call statement with one or two arguments, and you construct the URI in any of the following ways:
myResource String = JSONLib.convertToJson(myRec); call IRest.invokePost("http://www.example.com", myResource) returning to myCallbackFunction onException myExceptionHandler;
myBindingVar IHTTP{@Resource {uri = "binding:myEntry"}}; myResource String = JSONLib.convertToJSON(myRec); call IRest.invokePost("", myResource) using myBindingVar returning to myCallbackFunction onException myExceptionHandler;
myBindingVar IHTTP{@Resource {uri = "binding:myEntry"}}; myResource String = JSONLib.convertToJSON(myRec); myCustomerNumber String = "100"; call IRest.invokePost("customer/" + myCustomerNumber, myResource) using myBindingVar returning to myCallbackFunction onException myExceptionHandler;
function invokeDelete(reqURL string in) returns(string) {@deleteRest {uriTemplate="{reqURL}"}};