Skip to Content

Consuming On-Premise OData using XSJS in Multiple Cloud Connector Scenario

What is Multiple Cloud Connector Scenario ?

With new version release of SAP Cloud Connector , it is possible to connect different Backend system from Different Locations to one SAP Cloud Platform via multiple cloud connectors. Below Image helps to understand more.


I faced issue while connecting to the on-Premise systems due to the Location ID. Also couldn’t find access related issue in Cloud Connector.

In this blog i will technically help how to define the destination file and  setting the header parameter for Location in case of Multiple Cloud Connector scenario


Scenario : I want to consume an On-Premise OData service in SCP using XSJS based on a business requirement.

Note : We can use OData Provisioning in SCP for Connectivity to On-Premise OData Service.


Lets define Destination file : gateway.xshttpdest

host = "ecc.virtual.address";  // Virtual Host defined on Cloud Connector
port = 5000;                   // Virtual Port defined on Cloud connector
pathPrefix = "/sap/opu/odata/sap/EHS_INC_REPORTINCIDENT_SRV/"; // OData Service
useProxy = true;    // Its should be true , as we re using On-Premise system 
proxyHost = "localhost";  //connects, via a Cloud Connector tunnel, 
                         //to on-premise services and resources
proxyPort = 20003;     // Proxy Port
authType = basic;     // Authentication Type is Basic Authentication
useSSL = false;
timeout = 30000;


Maintain the Authentication details in XS ADMIN Tool.

The Basic Authentication details , it should be the User/Password of the On-Prem ECC System . 

After any changes in .xshttpdest file , need to update the User details in XS Admin Tool.Because its gets refresh after any changes .


Create a XSJS file to consume the service : GetLocation.xsjs

var destination_package = "Test_XSJS.OdataFromXSJS";     //
var destination_name = "gateway";          //e.g. demo
var dest = $.net.http.readDestination(destination_package, destination_name);
var client = new $.net.http.Client();
var response = client.getResponse();  
try {      

var req = new $.web.WebRequest($.net.http.GET, "Locations?$format=json");//Entity Set 
req.headers.set("SAP-Connectivity-SCC-Location_ID", "Bangalore");
// This is mandatory .Else the Call from XSJS fails to find the exact 
//cloud Cloud Connector Instance which is mapped to the Backend ECC System
req.headers.set("X-CSRF-Token", "CSRF");
client.request(req, dest);

$.response.contentType = "application/json";
$.response.status = $.net.http.OK;

 catch (e) 
$.response.contentType = "text/plain";


Activate the project and Run the XSJS . It should get the results .


Finally !! We have consumed an On-Prem OData Service in a Multiple Cloud Connector Scenario.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.