0
votes

Introduction

I have a SAP HANA Cloud Platform account. I have also deployed a Java application to the account and created a test servlet, which returns dummy data.

On the other side i have a SAP UI5 application which i develop on the WebIDE. I created also two destinations:

  • Destination "virtualTEST" is connected to a SAP Backend System (HANA Cloud Connector)
  • Destination "javaTEST" is connected to my Java servlet application

The neo-app.json is well configured and can obtain data from the test servlet (the dummy data) and data from the SAP Backend System (OData Gateway).

The problem

Now i want to pass variables to the SAP Backend System (virtualTEST) destination, which should not be visible in the frontend to avoid javascript manipulation.

My first thought

My first thought was that i create a new servlet which acts as proxy. In the SAPUI5 i call the servlet from javaTEST destination and pass the "hidden variables" like /testServlet?targetUrl=https://webide-xxx.hana.ondemand.com/sap/opu/odata/TEST_SRV/TEST?$filter=Var eq '{{MYVAR}}' and the Java application replaces {{MYVAR}} with my real variable. Then the target will be loaded (this is also a destination url to my SAPUI5 application). This does not work, i do not know why, but i think the proxy can not obtain data from the destination of an application.

Also, i think this is not the best solution. How can this be solved? Any ideas or best practices? Can destinations be used in Java application? :)

1

1 Answers

0
votes

It is not really clear to me what you want to achieve. Of cause you can call destinations from Java.

<resource-ref>
    <res-ref-name>myBackend</res-ref-name>
    <res-type>com.sap.core.connectivity.api.http.HttpDestination</res-type>
</resource-ref>

import javax.naming.Context;
import javax.naming.InitialContext;
import com.sap.core.connectivity.api.http.HttpDestination;
...

// coding to lookup the destination "myBackend"
Context ctx = new InitialContext();
HttpDestination destination = (HttpDestination) 
ctx.lookup("java:comp/env/myBackend");


    // coding to call service "myService" on the system configured in the given destination
    HttpClient createHttpClient = destination.createHttpClient();
    HttpGet get = new HttpGet("myService");
    HttpResponse resp = createHttpClient.execute(get);

from the official documentation. in the HttpGet you could set Params if you like. In my opion your Backend should be so save you don't have to worry about Javascript manipulations, especially not for exposed OData services

Regards Mathias