Skip to Content

How to connect sapui5 app with destination in CloudFoundry?

Hello,

I have a question about the connection between UI5 app and destination in CF.

In Neo environment I just create a destination and write the description in neo-app file, but how can I connect the app to the destination in CF?

Thank you in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 19 at 06:05 PM

    Hi Tatiana,

    Another way is to create an "User Provided Services" and call it as variable in your code. Once you assign this service as required to your application, CF will create a VCAP_SERVICES for it and will append this UPS. So the environment variables will be present at runtime.

    Please review this answer on the topic.

    Regards,
    Ivan

    Add comment
    10|10000 characters needed characters exceeded

    • Ivan Mirisola Tatiana Rastorgueva

      Hi Tatiana,

      You would define a destination as a user provided service (UPS) and bind it as a requires of the html5 module.

      Please take a look at this mta.yaml for an example.

      Look at the html5 module's require statement (module named web in the above example):

      requires:
      .....
      - name: EXTERNAL_UI5
        properties:
        ui5liburl: ~{url}

      In this example the UPS is EXTERNAL_UI5 and it can be created this way. Once created and referenced as a required service of my html5 module, you can reference it as a variable on html5 code like this:

      <script id="sap-ui-bootstrap" src="{{{ui5liburl}}}/resources/sap-ui-core.js"
        data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_belize">
      </script>

      Here is another way in which you could define it. Instead of creating a UPS, you could define it directly on your mta:

      - name: EXTERNAL_UI5
        type: org.cloudfoundry.user-provided-service
        parameters:
          service-name: EXTERNAL_UI5
          url: https://sapui5.hana.ondemand.com
        properties:
          ext-ui5-service-name: ${service-name}
          url: ${url}

      And how the same is referred in the html5 module:

      requires:
        - name: EXTERNAL_UI5
        properties:
        ui5liburl: ~{url}

      Either way, it can be referred to in the same way on your html5.

      Hope this helps,

      Ivan

  • Mar 05 at 05:45 AM

    Hello, Tatiana Rastorgueva. Could you check the post below, Please?

    Destination Configuration

    Unlike SAP Cloud Platform Neo, the Cloud Foundry environment does not offer a Destination API that application developers may use directly to connect to a resource over the web. But this limitation can be easily overcome through User-Provided Environment Variables and consuming them in your application.

    This is how it works on the Cloud Foundry environment.

    • In your SAP Cloud Platform Cockpit, access the application.
    • Define a new “User-Defined Variable”. An example could be: key = “ServiceDestination”. Value = [{name: “ServiceDestination”, url: “https://hostname.domain.com”, username: “Username”, password: “LoginPassword”}].
    • In your application, use this variable to call the respective service.
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 20 at 03:26 PM

    Hello Tatiana,

    The CF counterpart of neo-app.json to manage routes is the xs-app.json. You should also include the Application router (Approuter in short) part of your UI5 application as a separate module to take care of login process and routing. Finally, you should define the destinations either part of your manifest.yaml or mtad.yaml(in case of MTA deployments) under env section.

    Refer to this link for more details.

    Cheers!

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Tatiana and Yuvaraj Ramamurthy

      a HTML5 module inside an MTA (try with WebIDE Full-Stack creating a MTA and then create inside a HTML5 module) does automatically contain an app-router, however, there is nowhere a description on how to set the destination parameters (html5 module does not like env: in the mta.yml) in such a case.

      Regards,

      Wolfgang