Using Business Console Proxy for Invoking RESTful Services
In case the remote server cannot be configured to support CORS headers, Business Console provides a proxy service to route the request through the host My webMethods Server.
To use this option, you need to make a local RESTful POST call to My webMethods Server using /rest/bc/proxy URL. Provide the server options for fetching the data in the POST body. Provide data in a JSON format with escaped quotes.
$scope.restClient.url($scope.URLS.BC_PROXY)
//POINT TO THE RESTful SERVICE TO INVOKE
.serverAlias("MWS1")
// POINT TO THE SERVER ALIAS FROM THE GADGET CONFIGURATION
.remote(false)
// IF LOCAL OR REMOTE CALL
.method("POST")
.scope($scope)
.requestData(data)
//JSON Structure of the Request data. See below
.gadgetConfig(gadgetConfig)
.success(function(response,$scope){
$scope.responseData = response;
// HANDLE THE RESPONSE IN A SCOPE OBJECT
}).error(function(response,$scope,status, headers, config){
$scope.eventBus.fireEvent(NotificationConstants.ERROR,
"Unable to invoke RESTful service");
// HANDLE ANY ERROR IN INVOCATION
}).invoke();
Following are the example of different invocations
GET CALL TO IS
var data = { "serverType":"IS",
"url":"/rest/rs/monitor/process/model",
"requestMethod":"GET"
, "requestHeaders:{'key1':'value1','key2':'value2'}"
}
POST call to
Integration Servervar data = {"serverType":"IS",
"url":"/rest/rs/monitor/process/instanceSearch",
"host":"localhost",
"port":"5555",
"protocol":"http",
"requestMethod":"POST",
"data":"{\"instanceSearchQuery\":{\"processKey\":\"FeatureProject/Feature\",
\"pageNumber\":1,\"pageSize\":10,\"status\":\"2\",\"instanceId\":null,
\"customId\":null,\"businessConsoleRequest\":true}}"
"requestHeaders:{'key1':'value1','key2':'value2'}"
}
GET call to remote
My webMethods Servervar data = { "serverType":"MWS",
"url":"/rest/bc/userpreferences",
"host":"localhost",
"port":"8585",
"requestMethod":"GET",
"protocol":"http" (optional)
"requestHeaders:{'key1':'value1','key2':'value2'}"
}
POST call to remote
AgileApps Cloudvar data={
"serverType": "AA",
"url": "http://agileappsclound.info/networking/rest/login",
"requestMethod": "POST",
"data": "{\"platform\":{\"login\": {\"userName\":\"abc@softwareag.com\",
\"password\":\"test\"}}}"
}
GET call to remote
AgileApps Cloudvar data={
"serverType": "AA",
"url": "http://agileappsclound.info/networking/rest/user/info",
"requestMethod": "GET"
}