URL Rewrite Modes¶
For application back-end connections, the rewrite mode defines how the mobile services handles request and response messages.
Any mobile application can use multiple back ends that are registered based on the endpoint URL path, endpoint name, and
application name. The application is defined explicitly either by the application connection ID, or X-SMP-APPID
header, or URL Query parameter (see the rewrite mode descriptions below for details).
In case of applications with multiple mapped endpoints, the following endpoint is used:
-
On rewrite mode none, rewrite via SAP Business Technology Platform app or custom rewrite URL – the first part of the request path defines the endpoint name. For example,
https://<.....>/endpoint.A/cdef
forwards the request to endpoint.A. -
On rewrite in back end – the request path starts with the back-end path.
In case of multiple valid endpoints, the endpoint with the longest path is used.
To enable applications that use external back ends to run offline, select one of the supported rewrite modes.
Rewrite URL on Back End¶
The back end rewrites the URLs. The mobile services forwards the host name and port to the back end in an HTTP header, and the back end creates the URL to retrieve back-end resources.
To expose the full URL to clients, the mobile services passes the request path completely:
- Back-end URL –
http://ldcigm3.wdf.sap.corp:50057/sap/opu/odata/sap/FINCUSTFACTSHEET/
- URL exposed to clients –
http://<smphost>:<port>/sap/opu/odata/sap/FINCUSTFACTSHEET/
- URL format for Web applications –
https://<host>/<back-end path>?X-SMP-APPID=<applicationID>
, for examplehttps://mobiletest-xxxx.new.ondemand.com/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html?X-SMP-APPID=xxxxxBE
To transparently register Web-type applications, specify the application ID as the value of the X-SMP-APPID
parameter in the URL. Keep in mind:
- You can specify any application ID as the value of
X-SMP-APPID
. - If the application does not exist or has no valid endpoint in the specified path, it is not called.
Rewrite via Cloud Platform App¶
To enable requests to fetch data from HTML5 applications that are hosted on SAP Business Technology Platform, select Rewrite via Cloud Platform App. This sends the host information in the X-FORWARDED-FOR
header, and HTML5 applications send it to
back-end systems in the Host
header.
- If selected, the host name is sent to the back end in the
X-FORWARDED-FOR
HTTP header. - If not selected, the host name is sent to the back end in the
Host
HTTP header.
No Rewriting¶
Request and response messages are not modified; they are sent directly between clients and the back end.
Note
The mobile services does not provide the functionality to use No Rewriting mode to support external back ends for offline usage.
The URL format for Web applications is https://<host>/<applicationID>?X-SMP-APPID=<applicationID>
.
Custom Rewrite URL¶
For request and response messages, you can define a search string and a replacement string, which need not be URLs. Clients initiate incoming messages, which pass through the mobile services and terminate in the back-end system. Outgoing messages travel in the opposite direction.
If you select Custom Rewrite URL, click Next. In the Create Destination dialog, click the Add icon . On two separate screens, define the Inbound Rewrite Rules, and then the Outbound Rewrite Rules:
- Search For – string to find. To facilitate searching, you can use placeholder variables, for example, to find the
current application, enter
${SMP_APPID}
. - Replace With – replacement string. For example, you can convert an absolute URL to a relative URL by replacing
<http://host>
with an empty string. - Match Case – whether the case of the search string must match exactly.
- Regular Expression – allow regular expressions in the strings.
To define another rewrite pair, click the Add icon , and define the properties listed above. If you define more than one, you can sort them to change the order. The system works through the definitions, from top to bottom, searching for a Search For string that matches the input string from the client. For example, assume you define two rewrite pairs, in this order:
For this example, the system receives the input string <https://host/SAP>
from the client, which matches the Search
For string in the first definition, so it replaces the input string with <https://host/X>
. The system then looks at
the next rewrite definition, compares <https://host/X>
with the Search For string, finds a match, and replaces this
string with <https://host/Y>
; this is the output string.
If the definitions are in the reverse order, and the system receives the input string <https://host/SAP>
, the output
string would be <https://host/X>
; moving top to bottom, the matching definition is the last one.
To test a Custom Rewrite URL configuration for either inbound or outbound rules:
- Select the configuration, and click Test.
- In the Test Rewrite Rules dialog, enter the Input string.
- Click Rewrite. The replacement string appears under Output.
To edit or delete a configuration, select it, and click the appropriate icon.
Considerations¶
-
The base path of the URL must correspond to the path of the back-end URL. For other rewrite modes, the base path must contain the application ID (as in the example above).
-
If you change the value to or from Rewrite URL on Back End, inform the application developer of the change. He or she must update the application base URL accordingly, for both online and offline mobile application scenarios.
-
If you change the rewrite value, you must also reconfigure the mobile application.
-
Depending on other applications configured in your account, it may be impossible to detect from the URL which application is targeted; therefore, SAP recommends that you append the application ID as a URL parameter when you open the application in a browser, for example:
https://server/webapp?X-SMP-APPID=webapp
.If the URL needs additional query parameters, add them before the application ID, for example:
https://server/webapp?other=parameter&needed=true&X-SMP-APPID=webapp
.