External services Follow
The term "Services" (or "Internal Services") refers to the services created within AuraPlayer's ServiceManager - Forms / HTML / DB or JavaScript services.
In some cases you may require to integrate services that are external to the ServiceManager - to be called within JavaScript services, AppVisualizer apps or more.
A service external to the ServiceManager may be wrapped by a JavaScript service if it satisfies the following conditions:
- Service is REST service.
- Service receives input and returns output in JSON format.
- The service is accessible from the ServiceManager server.
Then you may call the external service from a JavaScript via the function:
Services.callExternal(httpMethod, url, input)
- httpMethod : string - GET, POST, PUT, PATCH or DELETE.
- url : string - URL of the service.
- input : object - undefined (for methods GET/DELETE), or JSON object which would be the body to be sent (for POST/PUT/PATCH).
GET example:
var getResponse = Services.callExternal('GET', 'https://jsonplaceholder.typicode.com/todos/4')
.response;
//console.log(JSON.stringify(getResponse));
return {
"title": getResponse.title,
"completed": getResponse.completed,
"id": getResponse.id
};
POST example:
var postResponse = Services.callExternal('POST', 'https://jsonplaceholder.typicode.com/posts',
{
"name": "AuraPlayer",
"summary": "completely transforms any Oracle EBS, without touching the back-end code or
jeopardizing its stability and performance.",
"country": "Israel"
}).response;
//console.log(JSON.stringify(postResponse));
return {
"name": postResponse.name,
"summary": postResponse.summary,
"country": postResponse.country
};
PUT example:
var putResponse = Services.callExternal('PUT', 'https://jsonplaceholder.typicode.com/todos/4',
{
"id": "1",
"title": "AuraPlayer",
"body": "completely transforms any Oracle EBS, without touching the back-end code or
jeopardizing its stability and performance.",
"userId": 1
}).response;
console.log(JSON.stringify(putResponse));
return {
"id": putResponse.id,
"title": putResponse.title,
"body": putResponse.body
};
PATCH example:
var patchResponse = Services.callExternal('PATCH', 'https://jsonplaceholder.typicode.com/posts/1',
{
"id": 16
}).response;
// console.log(JSON.stringify(patchResponse));
return {
"title": patchResponse.title,
"body": patchResponse.body,
"id": patchResponse.id
};
DELETE example:
var deleteResponse = Services.callExternal('DELETE', 'https://jsonplaceholder.typicode.com/posts/2')
.response;
//console.log(JSON.stringify(deleteResponse));
return {};
Another example:
var response = Services.callExternal('POST',
'http://34.216.95.17:7001/ServiceManager/Macro/ExecMacro/mcs_getCustomer', {
"MAIN_USERNAME_0": "MIA",
"MAIN_PASSWORD_0": "ORACLE",
"S_CUSTOMER_ID_0": "206"
});
console.log(JSON.stringify(response));
return {
"S_CUSTOMER_NAME_0": Services.getResponseValue(response, "S_CUSTOMER_NAME_0"),
};
Once the JavaScript service is created, it may be used like any other (internal) service in the ServiceManager.
Comments
0 comments
Please sign in to leave a comment.