Administrator

URL Rewrite Modes

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

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

  • URL Rewrite in Backend

  • No URL Rewrite

You set the URL rewrite mode for an application when you configure its back-end connection.

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, configure the relative URL patterns in Management Cockpit; on the application's back-end connection page, set the value of Relative Path. See Defining Back-End Connections.

URL Rewrite in SMP or No URL Rewrite

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

The client is registered with 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 an 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 and PDF documents are not changed.

SAP Mobile Platform Server replaces all instances of the back-end URL in HTTP request and response message bodies with its server URL. For example, the server rewrites both instances of the back-end URL http://services.odata.org/V2/Northwind in this HTTP request:
<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>
The same request after the server replaces the back-end URL with 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

You can use additional paths to map and rewrite a URL that has neither a host nor additional endpoint definitions. For example, if the previous example 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.

URL Rewrite in Backend

Some back ends can send and receive URLs that contain a host-name header, instead of their own server host name. Most servers such as SAP Gateway use the Host header. SAP Mobile Platform HTML5 and other applications use the x-forwarded-for header if you enable the Via HCP App property when you configure their back-end connections.

This rewrite option allows the back end to change the host name and TCP port of a URL to match the incoming request to SAP Mobile Platform Server; the path to the back end is not changed. This differs from the other rewrite options, in which the back-end connection name (often the same as the application ID) is the first segment of the path in the URL. The server adds its external name to the HTTP Host header, which is sent to the back end.

The Application ID is selected based on the Application Connection ID (which the client sends as a header or cookie). In the above example, the application maps to two back ends. The primary back end is available for requests that begin with <filepath>/odata/<filepath>; the secondary back end is available for requests that begin with <filepath>/service2/<filepath>.

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 to or from URL Rewrite in Backend, notify the application developer of the change. The developer must change the application's base URL to accommodate online and offline mobile applications.

    If you select URL Rewrite in Backend, 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.

  • Do not use these patterns in either application IDs (URL Rewrite in SMP) or mapped back-end paths (URL Rewrite in Backend), because SAP Mobile Platform Server publishes 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
  • Mixed content contains multiple parts. Each part is based on its own content type and can be rewritten independently.
  • If you select URL Rewrite in Backend, you cannot use the following endpoint paths:
    • /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/
  • If you select URL Rewrite in SMP, the server replaces:
    • Occurrences of the 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 
      
      Response: <a href=”https://anybackend.sap.com/oData/sample/Customers(‘4711’)” />
      is translated into:
      <a href=”https://smp.sap.com/demo/Customers(‘4711’)” />
    • 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’)” />
    • Escaped URLs such as "\/odata", "\\/odata", " &#x2f;odata", or "%2Fodata" with a similarly escaped URL.
  • The OData proxy can either rewrite GZIP files or deflate compressed responses. If a client supports GZIP compression, responses are compressed.