Show TOC

URL Rewrite ModesLocate this document in the navigation structure

SAP Mobile Platform Server OData proxy can be used to rewrite the content that is exchanged between client and back end. This is mainly used for OData requests and responses that can contain entity references as absolute URLs. These absolute URLs must be changed to refer to the external URL of the SAP Mobile Platform Server.

If an application requires data from a back end that uses relative URLs, that is, URLs that do not have a schema or host but have a path relative to the current document, you must configure those relative URL patterns in Management Cockpit, using the Relative Path field which is part of the application’s back-end connection configuration.

SAP Mobile Platform Server supports these URL rewrite modes:
  • URL Rewrite in SMP

  • URL Rewrite in Backend

  • No URL Rewrite

URL Rewrite in SMP or No URL Rewrite

In a typical setup, one application connects to one back end.

The client is registered to the application ID myapp and calls the OData proxy, providing the application ID as the first segment of the path. The OData proxy replaces the application ID with the configured back-end path /odata/service1 and forwards the request to the back end.

When the application has access to more than one back end, the name of the back end is used instead of the Application ID.

URL Rewrite in SMP

When URL Rewrite in SMP is selected, the server rewrites the HTTP request/response headers and most content. Binary data, such as images or PDF documents, is not rewritten.

SAP Mobile Platform Server replaces all of the back-end URLs found in the HTTP request or response message body with its server URL.

Example back-end URL: http://odata.service.org/V2/Northwind
<entry xml:base="http://services.odata.org/V2/Northwind/Northwind.svc/" 
						xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
						xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
						xmlns="http://www.w3.org/2005/Atom">
						<id>http://services.odata.org/V2/Northwind/Northwind.svc/Regions(1)</id>
						<title type="text"/>
						<updated>2015-12-04T15:17:04Z</updated>
						<author>
						<name/>
						</author>
						<link rel="edit" title="Region" href="Regions(1)"/>
						<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Territories" 
						type="application/atom+xml;type=feed" title="Territories" href="Regions(1)/Territories"/>
						<category term="NorthwindModel.Region" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
						<content type="application/xml">
						<m:properties>
						<d:RegionID m:type="Edm.Int32">1</d:RegionID>
						<d:RegionDescription xml:space="preserve">Eastern</d:RegionDescription>
						</m:properties>
						</content>
						</entry>
					
Rewritten SAP Mobile Platform Server URL: https//mysmp.sap.corp/myapp
<entry xml:base="https://mysmp.sap.corp/myapp/Northwind.svc/" 
							xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
							xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
							xmlns="http://www.w3.org/2005/Atom">
							<id>https://mysmp.sap.corp/myapp/Northwind.svc/Regions(1)</id>
							<title type="text"/>
							<updated>2015-12-04T15:17:04Z</updated>
							<author>
							<name/>
							</author>
							<link rel="edit" title="Region" href="Regions(1)"/>
							<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Territories" 
							type="application/atom+xml;type=feed" title="Territories" href="Regions(1)/Territories"/>
							<category term="NorthwindModel.Region" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
							<content type="application/xml">
							<m:properties>
							<d:RegionID m:type="Edm.Int32">1</d:RegionID>
							<d:RegionDescription xml:space="preserve">Eastern</d:RegionDescription>
							</m:properties>
							</content>
							</entry>
						
Using Additional Paths

Additional paths can be used to easily map and rewrite an URL without a host and without additional endpoint definitions. For example, if the previous service example also references a second service on the same host with the URL http://services.odata.org/V4/Northwind/Northwind.svc, simply add the path /V4/Northwind.

Rewrite URL in Backend

Some back ends can provide and understand URLs which contain a host name header instead of their own server host name. Most servers, like the Net Weaver Gateway, use the Host header HTML5 and other applications on SAP Mobile Platform use the x-forwarded-for header value, which is used when the respective option is selected. Select the option when you configure the back-end connection for the application in Management Cockpit.

This kind of URL rewrite only affects the hostname (and TCP port) of the URL. Therefore, SAP Mobile Platform Server makes the back end available under the same path that is supported by the back end natively. This differs from the other rewrite modes, which always assume that the Application ID (or Back End Connection name) is the first segment of the URL path.

The back end replaces the host only, therefore the request for this application is dispatched differently.

As usual, the Application ID is selected based on the Application Connection ID (which the client sends as a header or cookie). The above example shows two back ends are mapped to the application. The first is available for all requests starting with /odata/, and the other back end is available to URLs starting with /service2/.

Note

If you want to proxy a complete back end that is capable of rewriting, you can also specify a single backend URL with the path ‘/’, for example, http://services.odata.org/ . However, this will limit the application to a single backend, because the routing would be ambiguous otherwise.

Considerations

Keep the following limitations and considerations in mind when working with the OData Proxy Service.

  • To enable applications using an external back end to run offline, you must select one of the rewrite options.

  • If you switch the rewrite mode configuration to or from Rewrite URL in Backend System, notify the application developer of the change. The developer should change the application's base URL to accommodate online and offline mobile application scenarios.

    If you select Rewrite URL in Backend System, the base path of the URL must correspond to the path of the back-end URL. For example: http://ldcigm3.wdf.sap.corp:50057/sap/opu/odata/sap/FINCUSTFACTSHEET/

    For other rewrite modes, the base path must contain the Application ID. For example: https://<server host:port>/<back-end path>?X-SMP-APPID=<Application ID>

    SAP recommends that if you change the rewrite mode, you should also update the mobile-application configuration.

  • There are limitations for application IDs (URL rewrite in OData proxy) or mapped back end paths (URL rewrite in Backend System) because SAP Mobile Platform Server is publishing services on the same path.
    • Admin
    • btx
    • bundles
    • clientlogs
    • clientusage
    • hmadmin
    • logfiles
    • mobileservices
    • MobiLink
    • Notification
    • odata
    • public
    • resources
    • restnotification
    • SAMLAuthLauncher
    • system
    • tenantadmin
    • xsutils
  • When using URL Rewriting in the OData proxy, the following content types are rewritten.
    • application/atom+xml
    • application/atomsvc+xml
    • application/css
    • application/html
    • application/js
    • application/json
    • application/opensearchdescription+xml
    • application/rss+xml
    • application/x-www-form-urlencoded
    • application/xml
    • application/xhtml+xml
    • javascript
    • text/html
    • text/plain
    • text/xml
  • Multipart/mixed content contains multiple parts. Each part has its own content type and based on this content type, it can be rewritten independently.
  • The following endpoint paths cannot be used for URL rewrite in Backend System:
    • /Admin/
    • /btx/
    • /bundles/
    • /clientlogs/
    • /clientusage/
    • /hmadmin/
    • /logfiles/
    • /mobileservices/
    • /MobiLink/
    • /Notification/
    • /odata/applications/
    • /odata/lcm/
    • /public/bundles/
    • /public/odata/applications/
    • /resources/lcm/
    • /restnotification/
    • /SAMLAuthLauncher/
    • /system/
    • /tenantadmin/
    • /xsutils/
  • The URL rewrite in SMP replaces occurrences of back end host and path with <smphost>/<appID>. For example,
    Backend URL = https://anybackend.sap.com/oData/sample SMP URL = https://smp.sap.com/ 
    						Application ID = demo Sample 
    						Response: <a href=”https://anybackend.sap.com/oData/sample/Customers(‘4711’)” />
    is translated into:
    <a href=”https://smp.sap.com/demo/Customers(‘4711’)” />
  • Rewrite Mode in SMP also replaces paths without a host and schema (relative URLs). For example, this sample response:
    <a href=”/oData/sample/Customers(‘4711’)” /><a href=”/demo/Customers(‘4711’)” />
    is translated into this:
    <a href=”/demo/Customers(‘4711’)” />
  • In addition, escaped URLs like "\/odata", "\\/odata"," &#x2f;odata" or "%2Fodata" are replaced with a similar escaped URL.
  • The OData proxy can only rewrite gzip or deflate compressed responses. If the client supports gzip compression the response will be compressed.