Introduction
With this blog I would like to recap here all the steps to consume, with SAP Web IDE, data coming from a HANA XS instance located on the Trial landscape. There have been a lot of discussions around this topic on SCN, with many pieces spread around: for this reason I would like to show a step-by-step procedure to achieve this goal.
Let's give a look to the current architecture: if we want to connect our SAP Web IDE to an OData source like to the HANA XS instance we need to go through the creation of a destination in the HANA Cloud Cockpit, which connects on its turn to a Cloud Connector installed either on a local workstation or on a centralised server.
The Cloud Connector should be then able to connect to the HANA XS service. Unfortunately this is not possible on HANA Trial because for this landscape the Cloud Connector should be able to go through the SAML2 authentication, but as of now this is not possible.
To overcome this issue we could use a workaround, we could install a proxy in between the two things: HANA XS instance on one side and Cloud Connector on the other. This proxy server will be able to accept requests coming from Cloud Connector and translate them in SAML2 requests to forward to the HANA XS instance.
There is already a proxy, created by a SCN user, Gregor Wolf, that plays this role: it's located here.
The installation of this proxy is pretty simple and we'll see it in the next steps.
NOTE: for all SAP Employees, at moment this proxy only works if you are disconnected from the SAP Network. Pay also attention that when you are disconnected from SAP network also the Cloud Connector must be NOT using the SAP proxy.
Prerequisites
- A HANA XS OData service to consume on the HANA Trial platform
- SAP Web IDE 1.7+ (you can register at SAP HANA Cloud Platform to get your development environment)
- HANA Cloud Connector 2.5.1 downloadable from here
- Gregor Wolf's proxy downloadable from here
- NodeJS
Walkthrough
This is the list of the main steps we'll go through:
- Installation of the proxy
- Cloud Connector configuration
- Destination configuration
- Consuming the HANA XS service with SAP Web IDE
NOTE: For this exercise we are supposing that you already have a Trial HANA XS service to consume. If you don't have one or if you just want to create a basic one by yourself, you can follow another blog of mine:How to create a new OData service using the Web-Based Workbench
Let's get started!
1. Installation of the proxy
Let's start with the installation of the proxy. This is the piece with the green arrow you see in the architecture picture. It will take care of communicating with the HANA XS instance on the Trial landscape. For this reason we have to provide it with the URL to the HANA XS service.
- Download or clone the Git repository of the proxy located here
- If you have downloaded the package, extract it in a suitable folder of your drive
- Open a terminal window and go in the folder with the proxy. You should see something like this:
- Open the config.js file with your editor
- Choose the port you want to use for this proxy (by default it's set on 7891)
- Enter the host name taken form the URL string to the HANA XS service
(i.e. from "https://s6hanaxs.hanatrial.ondemand.com/i045523trial/dev/empdemo/services.xsodata" take just "s6hanaxs.hanatrial.ondemand.com")
- Leave the other options untouched and save the file
- Start the proxy with the command node server-basic-auth.js
- You can test the proxy by navigating to the following URL
http://localhost:7891<path_to_the_service>/$metadata where the <path_to_the_service> string is the part of the service URL after the host name (i.e. /i045523trial/dev/empdemo/services.xsodata)
- You should get something similar to this
- If you check the terminal window you can see that the proxy is forwarding the requests the browser issues to the HANA XS instance
2. Cloud Connector configuration
Let's now create a new access control in the Cloud Connector.
- Open the Cloud Connector administration console
- Click on the Access Control menu item and click on the Add button on the top
- Create a new mapping with the following settings and click on Save
Parameter | Value |
---|---|
Virtual Host | hanaxs.virtual |
Virtual Port | 8080 |
Internal Host | localhost |
Internal Port | 7891 |
Protocol | HTTP |
Principal Type | X.509 Certificate |
Back-end Type | Non-SAP System |
- For the added mapping, define also a new resource path
- As the URL path you need to specify the account name you get from the service URL prefixed with a "/" symbol (i.e. for https://s6hanaxs.hanatrial.ondemand.com/i045523trial/dev/empdemo/services.xsodata take just the red part) and select as access policy to get Path and all sub-paths. Then click on Save
- You should get something like this
3. Destination configuration
Create a new destination for the service URL you configured as the virtual URL in the Cloud Connector.
- Open your https://account.hanatrial.ondemand.com/cockpit# and select the Destinations menu
- Create a new destination (i.e. "hanaxs") with the following parameters:
Parameter | Value |
---|---|
Name | hanaxs |
Type | HTTP |
Description | hanaxs |
URL | <the virtual URL with port defined in the Cloud Connector (i.e. http://hanaxs.virtual:8080/)> |
ProxyType | OnPremise |
CloudConnectorVersion | 2 |
Authentication | BasicAuthentication |
User | <hana_trial_user_for_the_service> |
Password | <hana_trial_password_for_the_service> |
- Add these 3 additional properties as well
Property | Value |
---|---|
WebIDEUsage | odata_xs,odata_gen |
WebIDEEnabled | true |
WebIDESystem | <the same name of the destination> (i.e. hanaxs) |
- Save the destination, you should get something like this. It will take up to 5 minutes for the changes being applied
- If you want you can also test the destination by typing in the browser a URL like this:
https://webide-<your_hana_trial_account>.dispatcher.hanatrial.ondemand.com/destinations/hanaxs/<path_to_the_service>/$metadata
where <your_hana_trial_account> is the account you use for SAP Web IDE and <path_to_the_service) is the string just after the host name in your service URL
4. Consuming the HANA XS service with SAP Web IDE
The final step is to create a SAP Web IDE project to consume the OData service.
- Open SAP Web IDE
- Choose File --> New --> Project from Template
- Select one of the templates (i.e. SAP Fiori Master Detail application) and click on Next
- Enter the name of the application and click on Next
- On the Data Connection page, click on Service URL, choose the name of the destination you created in the previous step, enter the path to your OData service (you can omit the protocol and the host name since they are defined in the destination), click on Test and, once you get the details on the right, click on Next
- Define the fields you want to see in the application
- Click on Finish
- Run the application and you will get it perfectly working:
Congratulations! You have successfully consumed your HANA XS OData service with SAP Web IDE.