In the last two blog I have discussed about the expose of the DB artifacts like calculation view using XSJS and Xsodata service. This this blog I am going to discuss about the creation of a web module and integrating the Web application or module with XSJS and OData service which consuming consuming Database artifacts.
Previous links –
Create a XSJS application consume calculation view and sent it to Https in HANA XSA
Expose Calculation view as a service via OData in HANA XSA using Web IDE
Prerequisite :
Add the UAA service as a resource to the node.js Module for token authentication which will send from the Web module.
Also add the below in the require section of the Node.js module –
Steps :
1. Create a web HTML5 application using template .. Here it is demo_ui.
2. In MTA.YAML file inside HTML5 module, add the Node.js (with XSJS support) in the required field of HTML5 module with parameter name, URL and forwardAuthToken with value.
3. When the HTML5 Server/application(demo_ui) starts it first go to index.html. But route the control to Node.js module if a file with extension .xsjs or .Xsodata executes.
We need add the configuration to the xss-app.json file .
"routes": [{
"source": "(.*)(.xsjs)",
"destination": "demo_dest",
"csrfProtection": false,
"authenticationType": "xsuaa"
}, {
"source": "(.*)(.xsodata)",
"destination": "demo_dest",
"authenticationType": "xsuaa"
}]
4. Change the Servery.js file and comment // anonymous : true to activate the authentication method. The below line is responsible for authentication –
5. Change the Node version to “10.X” in the package. Json file –
6. Execute the HTML5 app and copy the url and replace the index.html file –
http://hcpeur10.hcs.cloud.sap:8000/employee. Xsodata?$format=json
http://hcpeur10.hcs.cloud.sap:8000/employee. xsjs?$format=json
or
http://hcpeur10.hcs.cloud.sap:8000/employee. Xsodata/$metadata
http://hcpeur10.hcs.cloud.sap:8000/employee. xsjs/$metadata
Note : if you execute URL while executing the Node.js URL then there is high probability to get the authentication error.
Reference SAP Link – https://github.com/sap-tutorials/
Hope this will help.