Developer

Creating Offline Demo Data

Create the offline demo data files.

Context

Procedure

  1. Query the service document in a browser and save the content.
    Name the service document file based on the download URL. Replace all special (?, :, \, /, =, *) characters with underscores.
    For example, rename this service document: http://servername.loc.sap.corp:50009/sap/opu/odata/GBHCM/LEAVEREQUEST as: http___servername.loc.sap.corp:50009_sap_opu_odata_GBHCM_LEAVEREQUEST.xml
  2. When the browser finishes downloading the content, select (in most browsers) Start of the navigation path File Next navigation step Save as End of the navigation path. Make sure you save the XML source rather than the HTML page the browser uses to visualize the XML file.
    • Internet Explorer: In the Save Webpage dialog, choose:
      • Webpage, source only (*.xml;…) for the service document and metadata, or
      • XML Files (*.xml) for feeds and data requests in the Save as type combo box.
    • Firefox: Select Start of the navigation path File Next navigation step Save Page As End of the navigation path. In the Save As dialog, choose:
      • Web Page, XML only or XML (*.xml) (depending on your Firefox version) for the service document and metadata.
      • WebPage, XHTML only for feeds and data requests in the Format combo box.
    • Safari: Select Start of the navigation path File Next navigation step Save As End of the navigation path. Enter the file name in the Export As field. For Format, select Page Source.
  3. Query the metadata document in a browser.
    Follow the naming procedure described in step 1.
    For example, for this metadata URL: http://servername.loc.sap.corp:50009/sap/opu/odata/GBHCM/LEAVEREQUEST/$metadata The expected file name is: http___servername.loc.sap.corp:50009_sap_opu_odata_GBHCM_LEAVEREQUEST_$metadata.xml.
  4. In your browser, execute an OData data request.
    Follow the naming procedure described in step 1.
    If the URL contains parameters, remove them from the file name and append a % character at the end. For example, for this filter request:
    http://servername.loc.sap.corp:50009/sap/opu/odata/GBHCM/LEAVEREQUEST/LeaveRequestCollection?$filter=StartDate EQ '2012-07-01T00:00:00' AND EndDate EQ '2013-12-31T00:00:00'
    This is the expected file name:
    http___servername.loc.sap.corp:50009_sap_opu_odata_GBHCM_LEAVEREQUEST _LeaveRequestCollection_$filter_StartDate_EQ_'2012-01-01T00_00_00'_AND_EndDate_EQ_'2012-12-31T00_00_00'.xml

    The library attempts to load this file: http___servername.loc.sap.corp:50009_sap_opu_odata_GBHCM_LEAVEREQUEST_.xml instead of http___servername.loc.sap.corp:50009_sap_opu_odata_GBHCM_LEAVEREQUEST.xml.

    Either add an extra underscore character to the file name, or remove the ending slash character from the URL when calling the setBaseURL method of the SDMDataSource class.

  5. If you need to use shorter file names due to technical constraints, use the following steps to save the service document, metadata, and data XML files with shorter names.
    In these examples, the <<host>>[:<port>] portion of the original URL has been replaced by the "serviceDocument" string. However, you can use another string instead of "serviceDocument".
    1. Save the service document and metadata as: http___serviceDocument.xml and http___serviceDocument_$metadata.xml
    2. To save a collection (list of entries), an entry (details), or a function import/search result, use the URL that retrieved the feed or entry as the file name, with these modifications:
      • Replace the <<host>>[:<port>] portion of the URL with the string "serviceDocument" (without quotes).
      • Replace all special characters with the underscore character.
    3. Open the http___serviceDocument.xml and replace the value stored by the xml:base attribute value with: http://serviceDocument/
    4. Open the saved collection, entry, or result of function import … files and replace the xml:base attribute value with: http://serviceDocument/
      Example file names:
      • http___serviceDocument.xml
      • http___serviceDocument_$metadata.xml
      • http___serviceDocument_LeaveRequestCollection.xml
      To use the renamed files:
      [SDMDataSource setDemoMode: YES];
      [SDMDataSource setBaseURL: @"http://serviceDocument"];