webMethods Business Console Documentation 10.5 | webMethods Business Console Documentation | Developing Gadgets for Business Console | Programming Gadgets | Invoking RESTful Services | Traditional Service for Invoking RESTful Services
 
Traditional Service for Invoking RESTful Services
You can use the invokeREST function defined under the RestService Angular service to invoke RESTful services.
* invokeREST function signature:
invokeREST:function(URLobj,successCallback,errorCallback,parameters,data,
scope, pathParams, gadgetConfig, isCrossOriginRequest, serverAlias)
* invokeREST function arguments:
*URL job: The URL object should point to a local URL object created under your controller. This can be defined under controller.
REST_URLS_OBJECT = {

REST_SVC_1: {url: '/rest/svc1',method:'GET', isArray:true},
REST_SVC_2: {url: '/rest/svc2',method:'GET', isArray:true},
}
For example, to use REST_SVC_1, use REST_URLS_OBJECT.REST_SVC_1 as your URLobj.
Note: All URLs defined here must be relative URLs without the host:port information. The host:port information will be fetched based on the serverAlias argument of the function call.
*successCallback:
* Success call back function signature:
var successFunc = function(response, status, headers, config,scope,
gadgetConfig){
// YOU SUCCESS HANDLER CODE GOES HERE


}
*Success call back function arguments:
*response: Function invocation success response
*status: HTTP status code of the response
*headers: {function([headerName])} to retrieve the header object
*config: The configuration object used to generate the request
*scope: The $scope object associated with the gadget controller
*gadgetConfig: The gadget configuration object. It contains the server list and any optional parameters that the gadget has been configured with
*errorCallback: This is the error callback function where the response will be passed when the invokeREST invocation fails. Arguments passed arguments to the error callback function:
*response: Error response from the invocation
*status: HTTP status code of the response
*headers: {function([headerName])}. This can be a function to retrieve the header object
*config: The configuration object used to generate the request
*scope: The $scope object associated with the gadget controller
*gadgetConfig: The gadget configuration object. It contains the server list and any optional parameters that the gadget has been configured with
*Parameters: JavaScript object to build the query parameters. Build the query as follows:
var parameters = new Array();
var param1 = new Object();
param1.name = "key1";
param1.value = value1;
parameters.push(param1);
param2.name = "key2";
param2.value = value2;
parameters.push(param2);
Query built: ?key1=value1&key2=value2
*Data: Required in case of POST and PUT calls. The request data object that can be passed to the server. It can be a String or a JSON object.
*Scope: The scope of the gadget in the AngularJS context. This will be passed back as part of the success callback function so that further actions can be taken
*pathParams: The path parameters that are appended to the URL string. If pathParams is a string, then it is directly appended to the end of the URL prior to the query parameters. If it is an Array, then the params string is constructed as follows:
var pathParams= new Array();
pathParams.push("param1");
pathParams.push("param2");
pathParams.push("param3");
URL constructed: URL/param1/param2/param2?<Query Param>
*gadgetConfig: The configuration of the gadget contains the server list and any optional parameters that the gadget has been configured with.
*isCrossOriginRequest: Set it to true in case of a Cross Origin Request to a server supporting CORS headers. Otherwise, set it to false to use a proxy invocation to remote server.
*serverAlias: The alias of the server to make the call to. The list of servers should be defined in the gadget configuration file and the selected alias should be passed here.

Copyright © 2014-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.