.xsapp and .xsaccess files

In our previous article Create Your First HANA XS Application using HANA Studio  and Create Your First HANA XS Application using HANA Web-based Tool, we showed you how to create a Hello World application in HANA.

In both the examples, you must have seen that there are 2 files which gets created automatically .xsapp and .xsaccess. These 2 files are mandatory for any HANA XS project
In this article, we will explain the importance of these 2 files.

SAP HANA XS Application Descriptor (.xsapp):

Each application that you want to develop and deploy on SAP HANA XS must have an application descriptor file.
The application-descriptor file has no name and no content; it only has the file extension “xsapp”, for example, .xsapp. For backward compatibility, content is allowed in the .xsapp file but ignored.

The .xsapp file marks the root folder of an SAP HANA XS application. All files in that package (and any sub-packages) are available to be called via URL.
If you remove this .xsapp file from your HANA XS project, then you will not be able to call the project components via URL.

Example:
If the package sap.test contains the file .xsapp, the application will be available under the URL
http://<host>:<port>/sap.test/

SAP HANA XS Application Access File (.xsaccess):

The application-access (.xsaccess) file enables you to specify who or what is authorized to access the content exposed by the application package and what content they are allowed to see.

The application-access file does not have a name before the dot (.); it only has the file extension .xsaccess. The contents of the .xsaccess file must be formatted according to JavaScript Object Notation (JSON) rules.

Example of .xsaccess file:
{
"exposed" : true,
"authentication" : { "method" : "Form"}
}

Important points about .xsaccess file:
  • The settings specified in an .xsaccess file apply not only to the package the .xsaccess file belongs to but also any sub-packages lower in the package hierarchy.
  • Multiple .xsaccess files are allowed, but only at different levels in the package hierarchy.
  • You cannot place two .xsaccess files in the same package.
  • The settings specified in an .xsaccess file in a sub-package take precedence over any settings specified in a .xsaccess file higher up the package hierarchy.
Continue reading:

1 comment: