cancel
Showing results for 
Search instead for 
Did you mean: 

How to access the CAP service in the SAP UI5 HTML in Native HANA On-Premise WEBIDE?

0 Kudos

Hello,

We have created a CAP project in On-Premise Native HANA WEBIDE and we have added the SAP UI5 HTML module in the project. We are trying to call the CAP services made in the project for UI development, but we are not able to call the service in the HTML project. I have attached the screenshot of the whole project hierarchy. Is there in any changes which are to be done in the mta.yaml file to access the services in the UI5 project(I have also attached the screenshot of the mta.yaml)?

Regards,

Atharva Singru

chgeo
Advisor
Advisor

Unfortunately the error information is very unspecific. When you say “ we are not able to call the service in the HTML project.”, what does that mean? What is the error that you get? Have you checked for logs (client side, CAP service)?

Accepted Solutions (0)

Answers (4)

Answers (4)

yuval_morad
Employee
Employee
0 Kudos

please change the default model to V2

and in daya source section add the right suffix of your service, I just gave sample

"uri": "/catalog/"

this is the model V2

"": {"dataSource": "mainService","settings": {"defaultBindingMode": "TwoWay","defaultCountMode": "Inline","refreshAfterChange": false}}

yuval_morad
Employee
Employee
0 Kudos

We can have a call tomorrow.

Does it fail in deployment or local run?

is it OData V2 or V4?

0 Kudos

Hi Yuval,

Yes we can have a call tomorrow, will send you a mail regarding this.

It fails while we try to run it locally.

It is OData V2.

Regards

Atharva Singru

yuval_morad
Employee
Employee
0 Kudos

my mistake the requires of srv_api part should be inside the html5 module, so please remove it from srv module and move to html5

requires:

- name: srv_api

group: destinations
properties:
name: srv_api
url: ' ~{url}'
forwardAuthToken: true

0 Kudos

Hi Yuval,

We tried with this change but we still are facing issue, I have attached the chnages done on the mta.yaml and the screenshot of the error

mta.yaml is like this now:

version: 0.0.1
modules:
- name: hanademo-db
type: hdb
path: db
parameters:
memory: 256M
disk-quota: 512M
requires:
- name: hanademo-db-hdi-container
- name: hanademo-srv
type: nodejs
path: srv
parameters:
memory: 512M
disk-quota: 512M
provides:
- name: srv_api
properties:
url: '${default-url}'
requires:
- name: hanademo-db-hdi-container
- name: hanademo-uaa
- name: demo
type: html5
path: demo
requires:
- name: srv_api
group: destinations
properties:
name: srv_api
url: '~{url}'
forwardAuthToken: true
resources:
- name: hanademo-db-hdi-container
type: com.sap.xs.hdi-container
properties:
hdi-container-name: '${service-name}'
- name: hanademo-uaa
type: org.cloudfoundry.managed-service
parameters:
service-plan: default
service: xsuaa
config:
xsappname: hanademo
tenant-mode: dedicated

The error is like this :

How can we solve this error?

Regards

Atharva Singru

yuval_morad
Employee
Employee
0 Kudos

I assume this is WebIDE for HANA on premise, thus no HTML5 service exists and each UI has its own approuter application.

1. Please add the following to your HTML5 app in mta.yaml:

requires:

- name: srv_api

group: destinations

properties:

forwardAuthToken: true

name: srv_api

url: '~{url}'

2. add a route in xs-app.json:

{

"source": "/srv_api/(.*)$",

"target": "$1",

"authenticationType": "none",

"destination": "srv_api",

"csrfProtection": false },

3. make sure you have a data source in manifest.json with your service name in this case it is called catalog in bold:

under sap.app section -

"dataSources":

{

"mainService": {

"uri": "/srv_api/<catalog>/",

"type": "OData",

"settings": { "odataVersion": "4.0", "localUri": "localService/metadata.xml" }

}

},

4. make sure you have a default "" model section in manifest.json in this case it is OData V4:

under sap.ui5 section -

"": {

"dataSource": "mainService",

"preload": true,

"settings": { "operationMode": "Server", "groupId": "$direct", "synchronizationMode": "None", "autoExpandSelect": true }

}

0 Kudos

Hi Yuval,

We tried with this way but we are facing issue, I have attached the Log file and the screenshot of mta.yaml, xs-app.json and manifest.json.

1. mta.yaml file is like this :

ID: hanademo
_schema-version: '2.1'
version: 0.0.1
modules:
- name: hanademo-db
type: hdb
path: db
parameters:
memory: 256M
disk-quota: 512M
requires:
- name: hanademo-db-hdi-container
- name: hanademo-srv
type: nodejs
path: srv
parameters:
memory: 512M
disk-quota: 512M
provides:
- name: srv_api
properties:
url: '${default-url}'
requires:
- name: hanademo-db-hdi-container
- name: hanademo-uaa
- name: srv_api
group: destinations
properties:
name: srv_api
url: ' ~{url}'
forwardAuthToken: true
- name: demo
type: html5
path: demo
resources:
- name: hanademo-db-hdi-container
type: com.sap.xs.hdi-container
properties:
hdi-container-name: '${service-name}'
- name: hanademo-uaa
type: org.cloudfoundry.managed-service
parameters:
service-plan: default
service: xsuaa
config:
xsappname: hanademo
tenant-mode: dedicated

2. manifest.json is like this:

(a)

"dataSources": {
"shipper-vessel": {
"uri": "/catalog/",
"type": "OData",
"settings": {
"odataVersion" : "2.0",
"localUri": "localService/metadata.xml"
}
}
}

(b)

"": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request",
"groupId": "$direct",
"synchronizationMode": "None",
"autoExpandSelect": true
},
"dataSource": "shipper-vessel",
"preload": true
}

3. xs-app.json is like this :

{

"welcomeFile": "webapp/index.html",

"authenticationMethod": "none",

"routes": [

{

"source": "/srv_api/(.*)$",

"target": "$1",

"destination": "srv_api",

"csrfProtection": false,

"authenticationType": "none" }

]

}

4. The error which we are getting is being attached :

log.txt

Regards

Atharva Singru