cancel
Showing results for 
Search instead for 
Did you mean: 

How to set and use destinations in XSA | Cloud Foundry

FabioPagoti
Active Contributor
0 Kudos

I have a scenario where I am developing UI5 apps and deploying them in HANA XSA (on premise).

HDB 2.00.010.00.1491294693

v1.0.55 (built 2017-04-10)

Although the UI5 code is inside HANA XSA, the backend service is hosted in a different environment - so I need a destination to call some REST and oData APIs.

I created two different spaces in my HANA XSA Organization: the objective is to use one space for development purposes (SPACE_DEV) and the other one for production (SPACE_PROD).

Similarly, the backend has two different environments for development (API_DEV) and production (API_PROD).

So, I would like that the apps deployed in SPACE_DEV end up calling API_DEV and when they are deployed to SPACE_PROD end up calling API_PROD.

There is some information about manifest.yaml, xs-app.json and destinations but always those examples consider that the backend is a module in the same MTA app where the front end is in.

The (only) most similar question I have found at the community is below - but I do not have a back end service in HANA on which I would need to call an REST API.

https://answers.sap.com/questions/183224/https-destinations-xshttpdest-in-xsa.html

Accepted Solutions (0)

Answers (2)

Answers (2)

matheusog
Participant
0 Kudos
pfefferf
Active Contributor
0 Kudos

A user provided service is not only restricted for calls to a HANA "backend". With a user-provided service you can create a "service" for nearly every endpoint.

In the OpenSAP course (v5) for HANA development there was an example to use the external UI5 library of the CDN. The create command can be found here. If you check the mta.yaml file, you see that the ups is consumed as resource which is required by the web module (not really anymore, cause it was replaced by the HANA provided UI5 lib, but you can see the commented config lines in the file). In the index.html file of the web module you can see that the ui5liburl property is replaced by the real URL using the {{{ }}} replacement syntax.

In a Node.js or Java module (or BYOL module) you are able to read such values via the VCAP_SERVICES environment variable.

The same way you can consume your REST service.

Regards,
Florian

FabioPagoti
Active Contributor
0 Kudos

Hi Florian, thanks for the answer.

I will try this out today. As my understanding, this cups command would be used in different spaces with different URLs, right? (In order to differentiate back end systems for each space)

Thank for now. I will be back

matheusog
Participant
0 Kudos

Hi Florian,

I did this, but i'm having an error of authentication.

My .NET API needs Bearer authentication, and i'm passing it on HTTP header request.

I've already did set the Authorization as 'none' in xs-app.json and executing the application as stand-alone works fine, but when i tried to execute it inside a Launchpad, the router is tring to authenticate the Bearer token into Hana and returns me a HTTP 401 Authorization error.

Any idea of what this could be?

Thanks!