Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

How to consume a HANA XS service on the HANA Trial landscape

$
0
0

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.

2015-03-13_12-36-12.png

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:

  1. Installation of the proxy
  2. Cloud Connector configuration
  3. Destination configuration
  4. 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:

2015-03-16_12-24-17.png


  • 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

2015-03-16_12-26-12.png

 

  • Start the proxy with the command node server-basic-auth.js

2015-03-16_12-30-33.png


  • 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

2015-03-16_12-32-03.png


  • If you check the terminal window you can see that the proxy is forwarding the requests the browser issues to the HANA XS instance

2015-03-16_12-33-54.png



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

2015-03-16_12-37-55.png

 

  • Create a new mapping with the following settings and click on Save
ParameterValue
Virtual Hosthanaxs.virtual
Virtual Port8080
Internal Hostlocalhost
Internal Port7891
ProtocolHTTP
Principal TypeX.509 Certificate
Back-end TypeNon-SAP System

 

2015-03-16_12-38-56.png

 

  • For the added mapping, define also a new resource path

2015-03-16_12-39-19.png

 

2015-03-16_12-39-44.png

 

  • You should get something like this

2015-03-16_12-40-10.png

 

 

3. Destination configuration

Create a new destination for the service URL you configured as the virtual URL in the Cloud Connector.


  • Create a new destination (i.e. "hanaxs") with the following parameters:
ParameterValue
Namehanaxs
TypeHTTP
Descriptionhanaxs
URL<the virtual URL with port defined in the Cloud Connector (i.e. http://hanaxs.virtual:8080/)>
ProxyTypeOnPremise
CloudConnectorVersion2
AuthenticationBasicAuthentication
User<hana_trial_user_for_the_service>
Password<hana_trial_password_for_the_service>

 

  • Add these 3 additional properties as well

 

PropertyValue
WebIDEUsageodata_xs,odata_gen
WebIDEEnabledtrue
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

2015-03-16_12-53-39.png

 

  • 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

10.png

 

 

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

2015-03-16_13-05-43.png

 

  • Define the fields you want to see in the application

2015-03-16_13-09-40.png

 

  • Click on Finish

 

  • Run the application and you will get it perfectly working:

2015-03-16_22-21-38.png

 

 

Congratulations! You have successfully consumed your HANA XS OData service with SAP Web IDE.


Viewing all articles
Browse latest Browse all 789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>