Developer

Initializing an Online Store

Initialize an online OData store for online OData access.

Prerequisites

Define the back-end OData connections required by the application in the SAP Mobile Platform Server Management Cockpit or HANA Cloud Platform Mobile Services Cockpit. For detailed information see SAP Mobile Platform http://help.sap.com/mobile or SAP HANA Cloud Platform Mobile Platform https://help.hana.ondemand.com/hana_cloud_platform_mobile_services/frameset.htm.

Context

The ODataOnline library interacts extensively with the OData service. One SODataStore instance interacts with one OData source: If a SAP Mobile Platform Server-hosted application is defined with two or more back-end URLs (whitelisted connections), a separate ODataOnlineStore instance is required for each. Pass in the URL as a NSURL, which must be the baseURL of the OData service. The HttpConversationManager is the network layer, which handles the authentication challenges, and can be configured manually or by using the MAFLogonManager. The SODataOnlineStore hides many of the complexities of interacting with the OData source, and internally uses an OData parser.

Procedure

  1. Opening an Online Store requires HttpConversationManager, which you configure with the MAF Logon configurator:
    self.conversationManager = [[HttpConversationManager alloc] init];
    [self.logonUIViewManager.logonManager.logonConfigurator 
    configureManager:self.conversationManager];
    
  2. Create an online SODataStore. There are two overloaded constructors for the SODataStore:
    -(id) initWithURL:(NSURL*)url httpConversationManager:
    (HttpConversationManager*)httpConversationManager;
    
    -(id) initWithURL:(NSURL*)url httpConversationManager:
    (HttpConversationManager*)httpConversationManager options:(SODataOnlineStoreOptions*)options;
    
    Using the JSON format greatly reduces network traffic:
    //Use options to configure the store to send the request payload in JSON format
    SODataOnlineStoreOptions* const storeOptions = [[SODataOnlineStoreOptions alloc] init];
        storeOptions.requestFormat = SODataDataFormatJSON;
    
    onlineStore = [[SODataOnlineStore alloc] initWithURL:url   
    httpConversationManager:manager options:storeOptions];