Skip to Content
Author's profile photo SIMMACO FERRIERO

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

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.

/wp-content/uploads/2015/03/2015_03_13_12_36_12_666750.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.

Prerequisites

  • A HANA XS OData service to consume on the HANA Trial platform
  • SAP Web IDE (you can register at SAP HANA Cloud Platform to get your development environment)
  • HANA Cloud Connector 2.7.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 (v2.0)

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:

/wp-content/uploads/2015/03/01_912492.png


  • Inside the folder hanatrial-auth-proxy, run the command npm install in order to install all the required packages
  • Open the example/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/myproducts/services.xsodata” take just “s6hanaxs.hanatrial.ondemand.com”)

  • Leave the other options untouched and save the file. In case you are behind a proxy firewall, you need to uncomment the proxy line in this file and enter the correct proxy address and port for your network

/wp-content/uploads/2015/03/02_912493.png

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

/wp-content/uploads/2015/03/2015_03_16_12_30_33_666800.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/myproducts/services.xsodata)


  • You should get something similar to this

/wp-content/uploads/2015/03/28_916576.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

/wp-content/uploads/2015/03/29_916595.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

/wp-content/uploads/2015/03/2015_03_16_12_37_55_666830.png

  • Set “Non-SAP system” as the Back-end type
  • Set “HTTP” as Protocol
  • Enter “localhost” as Internal Host and “7891” as Internal Port
  • Enter “hanaxs.virtual” as Virtual Host and “8080” as Virtual Port
  • Set “None” as Principal Type
  • Leave the Description blank
  • Click on Finish

    /wp-content/uploads/2015/03/08_912539.png

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

/wp-content/uploads/2015/03/2015_03_16_12_39_19_666831.png

/wp-content/uploads/2015/03/06_912540.png

  • You should get something like this

/wp-content/uploads/2015/03/07_912552.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:
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

/wp-content/uploads/2015/03/2015_03_16_12_53_39_666834.png

  • If you want you can also test the destination by typingin 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

/wp-content/uploads/2015/03/30_916609.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 project 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

/wp-content/uploads/2015/03/31_916597.png

  • Define the fields you want to see in the application

/wp-content/uploads/2015/03/32_916607.png

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

/wp-content/uploads/2015/03/33_916608.png

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

Assigned Tags

      22 Comments
      Comments are closed.
      Author's profile photo Wouter Lemaire
      Wouter Lemaire

      Hi Simmaco Ferriero ,

      Thanks for posting!  Very interesting!

      Just a small question. What if you want deploy your SAPUI5 app to the HANA Cloud Platform, will this work without the proxy? Or will you have to export your SAPUI5 app from the Web IDE and import it directly in your HANA Cloud XSEngine?

      Kind regards,

      Wouter

      Author's profile photo SIMMACO FERRIERO
      SIMMACO FERRIERO
      Blog Post Author

      Hi Wouter,

      I think that for deploying you don't need the proxy. You can just do it from SAP Web IDE. Let us know the results if you try it.

      Regards,

      Simmaco

      Author's profile photo Denise Nepraunig
      Denise Nepraunig

      Hey Wouter,

      it makes no difference if you run the SAPUI5 application inside the the SAP Web IDE or if you have deployed it to the SAP HANA Cloud Platform because they both use the same "destination service". At the moment the SAPUI5 apps can not "easily" talk to HANA XS which is a pity.

      Best would be really at the end to copy the application over to HANA XS.

      I cover that in my blog post:

      Accessing HANA XS OData in Web IDE and beyond 

      Author's profile photo Wouter Lemaire
      Wouter Lemaire

      Thanks Simmaco Ferriero and a28 guest for the reply!

      Denise, That's what I was thinking. I've already seen your blog. The proxy is another option like your mockdata solutions to close the gap between HANA and the Web IDE.

      Kind regards,

      Wouter

      Author's profile photo Christian Geyer
      Christian Geyer

      A beginner's question: Is this workaround actually still required? Or has the trial account's Web IDE learned to access XS OData services in the meantime?

      Author's profile photo Denise Nepraunig
      Denise Nepraunig

      I am afraid that it is still not possible, I am in contact with our (SAP) people, but no solution in sight.

      Author's profile photo Christian Geyer
      Christian Geyer

      Well, in any case thanks a lot for looking into this and, especially, keeping on it. Great work!

      Author's profile photo Former Member
      Former Member

      Hi SIMMACO FERRIERO,

      I am trying to do above, node server-basis-auth.js commands is giving error, seems it unable to find some file.

      Capture.PNG

      I have downloaded node.js setup for windows from Node.js and installed it, downloaded proxy from git mentioned above, i can see your directory listing is little different then me for proxy listing like i have server-basic.js in examples folder, hana-saml.js in lib folder and you have node-modules directory for me its in Program files after installing node.js, any way i tried so copied in one place, even though no luck.

      Directory Structure

      C:\hanatrial-auth-proxy-master>dir

      Volume in drive C has no label.

      Volume Serial Number is 6222-7909

      Directory of C:\hanatrial-auth-proxy-master

      09/11/2015  02:03 PM    <DIR>          .

      09/11/2015  02:03 PM    <DIR>          ..

      09/11/2015  02:03 PM                13 .gitignore

      09/11/2015  02:03 PM    <DIR>          examples

      09/11/2015  02:03 PM                85 index.js

      09/11/2015  02:03 PM    <DIR>          lib

      09/11/2015  02:03 PM            11,357 LICENSE

      09/11/2015  02:03 PM               707 package.json

      09/11/2015  02:03 PM             3,875 README.md

                     5 File(s)         16,037 bytes

                     4 Dir(s)  72,449,527,808 bytes free

      C:\hanatrial-auth-proxy-master>cd examples

      C:\hanatrial-auth-proxy-master\examples>dir

      Volume in drive C has no label.

      Volume Serial Number is 6222-7909

      Directory of C:\hanatrial-auth-proxy-master\examples

      09/11/2015  02:03 PM    <DIR>          .

      09/11/2015  02:03 PM    <DIR>          ..

      09/11/2015  02:03 PM               210 config.js

      09/11/2015  02:03 PM             1,437 saml-client.js

      09/11/2015  02:03 PM             5,086 server-basic-auth.js

                     3 File(s)          6,733 bytes

                     2 Dir(s)  72,449,527,808 bytes free

      C:\hanatrial-auth-proxy-master\examples>cd ..

      C:\hanatrial-auth-proxy-master>cd lib

      C:\hanatrial-auth-proxy-master\lib>dir

      Volume in drive C has no label.

      Volume Serial Number is 6222-7909

      Directory of C:\hanatrial-auth-proxy-master\lib

      09/11/2015  02:03 PM    <DIR>          .

      09/11/2015  02:03 PM    <DIR>          ..

      09/11/2015  02:03 PM             5,111 hana-saml.js

                     1 File(s)          5,111 bytes

                     2 Dir(s)  72,444,809,216 bytes free

      Node.js

      C:\Program Files\nodejs>dir

      Volume in drive C has no label.

      Volume Serial Number is 6222-7909

      Directory of C:\Program Files\nodejs

      09/11/2015  01:35 PM    <DIR>          .

      09/11/2015  01:35 PM    <DIR>          ..

      09/08/2015  03:31 PM        13,000,296 node.exe

      09/02/2015  11:33 AM               700 nodevars.bat

      09/02/2015  11:33 AM             6,612 node_etw_provider.man

      09/11/2015  01:35 PM    <DIR>          node_modules

      09/02/2015  11:33 AM             4,974 node_perfctr_provider.man

      09/05/2015  05:54 AM               623 npm

      09/07/2015  02:13 AM               483 npm.cmd

                     6 File(s)     13,013,688 bytes

                     3 Dir(s)  72,444,436,480 bytes free

      Thanks

      Saurav Kumar Suman

      Author's profile photo Michael Appleby
      Michael Appleby

      Hi Saurav,

      Please create a Discussion marked as a Question with your issue.  It will get better visibility and it is also the proper way to proceed.

      Regards, Mike (Moderator)

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Hi,

      I solved this issue, actually we have to change one line in server-basic-auth,js which is actually inside examples folder.

      Replace line

      var request = require('request');

      with

      var request = require('C:/Program Files/nodejs/node_modules/npm/node_modules/request/request');

      Thanks

      Saurav Kumar Suman

      Author's profile photo Lalith Manokar S
      Lalith Manokar S

      Hi Saurav Kumar,

      I have also tried to do proxy settings, but i am facing an error.

      After running the code, i can able to see the credentials Popup but once i give the credentials, i am getting this error.

      image.JPG

      Author's profile photo Former Member
      Former Member

      Hi Lalitha,

      I am also getting same error can you please help if you are solved..

      Saurav and Simmaco please help if you know the problem

      Author's profile photo Former Member
      Former Member

      Hi Lalitha,

      I'm also getting this error. How did you solve it?

      Thanks

      Raissa Almeida

      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      Couldn't one develop a J2EE web application running on the HCP trial account acting as the proxy to access the XSODATA service? I think there are APIs available support SAML2 forwarding (cf AuthenticationHeaderProvider (SAP HANA Cloud Platform SDK)?

      The HCP HTML5 app should be able to access the HCP Java application without problems.

      Regards,

      Wolfgang

      Author's profile photo Former Member
      Former Member

      Hi Wolfgang Röckelein ,

      Looks great, from where to start, i googled but no luck din't get any valuable document, can you please suggest how to  and where to start.

      Thanks

      Saurav Kumar Suman

      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      If you look at the HCP documentation, you will find explanation on how to create a J2EE Web Profile application eg in eclipse which you can then deploy to the HCP account as an Java application.

      The application just needs one Servlet which forwards the connection to a new HTTP connection targeted at the XSODATA service utilizing the referenced auth provider.

      Author's profile photo Denise Nepraunig
      Denise Nepraunig

      Hey, when I was trying to solve this problem I stumbled upon this document - maybe this helps.

      SAPUI5, ODATA and anonymous database access in the HCP: How to do it

      It is right that the Java solution would be easier. But for me - SAPUI5 = JavaScript, HANAXS native development = JavaScript, both have Cloud IDEs from SAP. Node.js is lightweight and I don't need fancy IDEs to develop node apps.

      I don't speak Java and I don't want to fiddle around with an on-prem Eclipse installation and Java installation 😉 #JavaScriptFanGirl

      Author's profile photo Andy Bloem
      Andy Bloem

      Hi,

      I did the same but when I execute my application, I don't see my data from the XS service, but mock data:

      Clipboard01.jpg

      this is the data:

      {

      }}

      Author's profile photo Former Member
      Former Member

      Hi Andy,

      By default when you run a project it's running with mock data.

      Try to right click on the project and select run with server and then it should do the trick.

      Author's profile photo Former Member
      Former Member

      Hi,

      I have follow the steps and everything works fine until I run the project with run with server option.

      I get an error

      {

        "message": "HTTP request failed",

        "headers": [],

        "statusCode": 403,

        "statusText": "Forbidden",

        "responseText": "Request execution failed due to missing or invalid XSRF token"

      }

      In node.js window i can see the HEAD GET AND POST and just after POST I get Header expires is undefined.

      Any idea how can I fix this?

      Author's profile photo Andy Bloem
      Andy Bloem

      Hi Marius,

      check your .xsaccess file, is there a parameter prevent_xsrf ?

      by default, this is set to false.

      if it is set to true, you should apply for an xsrf token:

      https://help.sap.com/saphelp_hanaplatform/helpdata/en/e8/a6bc904c0c48a182288604f467e84a/content.htm

      I setted that parameter on false, and it worked.

      KR.

      Author's profile photo Marcel Gatermann
      Marcel Gatermann

      Hello,

      I have one issue that I can not solve by my own.

      In the HANA Cloud Connector, I can not choose X.509 Certification, it is grey and not selectable.

      Without Principle Type None it doesn't work. I get an:

      HTTP Status 500 - Internal Server Error

      All the steps before are sucessfull.

      Any ideas?

      Did I miss a step?

      Best regards,

      Marcel

      Comments are closed.