Skip to content

Using ODataOnlineCore library to connect to SMP Server

In order to efficiently exercise SMP Server OData service we would like to first generate set of OData proxy classes.

The purpose of this library is to make registration, de-registration and handling application settings easier for application developers. Before a client application start to use a service configured in an SMP server the application must register to that SMP. SMP server provides an OData service where a new Connection entity must be created, or deleted in order to register or de-register the client. This library contains proxy classes for this service.

Note that this library also compatible with SAP Cloud Platform

Generating applications Proxy Classes

SMP SDK comes with pre-generated OData proxy classes. As such this is just a convenience framework. It contains only generated code. In spite of our best effort to maintain this library as often as possible you may require to re-generate the content for your application.

Collecting $Metadata xml from SMP Server

In order to generate OData proxy classes you will need to download $Metadata XML document from the SMP server.

$ curl -o Applications.xml http://<hostname_of_your_smp_server>:8080/odata/applications/v4/<APPLICATION_ID>/$metadata

You may need to provide credentials to access this document.

Generating XS script from $Metadata

In order to generate XS script from the $Metadata you need to use the xscript proxy-generator-mobile utility that comes with the SMP SDK package.

$ sh Applications.xml Applications.xs -service "Applications" -generic -pretty -oc OC

This should have created an XS file.

Compiling ObjectiveC proxy classes from XS script file

In order to use the Proxy Classes in an ObjectiveC Xcode project you will need to compile the XS file with xs compiler.

$ sh Applications.xs -oc -pi -d output

This should generate a set of Objective C files that you need to add to your Xcode project.


  1. Clients must crate a HTTPConversationManager object and configure it according to the authentication method of server. The example in this document use basic authentication. It's recommended to take a look at HttpConversation developer guide for details about other authentications like SAML2 or OAuth2.
self.manager = [HttpConversationManager new];
//add here configuration code as per HttpConversationManager developer guide.
  1. Create applications object and configure it to use the conversation manager created in the first step. By default the URL of this registration service looks like this: "https://serverHost:serverPort/odata/applications/v4/yourApplicationID"
    //Create a Provider with the real url from SMP Cockpit application overview
    SODataV4_OnlineODataProvider* provider = [SODataV4_OnlineODataProvider new:@"SMP Server Application Service" :[HOST stringByAppendingString:CONN]];

    SODataV4_HttpConversationHandler *odatamanager = [[SODataV4_HttpConversationHandler new] initWithManager:self.manager];
    [provider.networkOptions setHttpHandler:odatamanager];

    provider.serviceOptions.checkVersion = false;
  1. Use applications to create a new connection. For creating connection only one property is relevant, the DeviceType must be set to “iPhone”
    //The registration eq creating a connection
    Connection *connection = [Connection new];
    connection.deviceType = @"iPhone";
    //setting apns device token and sending it up to the server
    connection.apnsDeviceToken = self.delegateRef.strDeviceToken;
    SODataV4_HttpHeaders *headers = [SODataV4_HttpHeaders new];
    //we set this as header so that we can make the SMP Server use this exact appcid. It is necessary so that we can clean up in teardown
    //and we want random each time
    self.randAppcid = [[NSUUID UUID] UUIDString];
    [headers set:@"X-SMP-APPCID" :self.randAppcid];

    @try {
        [self.applications createEntity:connection :headers];
    } @catch (SODataV4_DataServiceException *ex){
        NSLog(@"[CREATE CONNECTION]Exception occured during odata operation ex: %@", ex);


After a Connection successfully created the server responds with application settings configured in the server and the Connection object will contains application settings relevant for the application. Please check SMP documentation about the meaning of different settings.

In case you need to acquire a new session to the SMP Server you can do so by getting another connection object that will be binding to the new SMP Server session.

    Connection *connection = [Connection new];
    connection.applicationConnectionID = self.randAppcid;
    @try {
        [self.applications loadEntity:connection];
    } @catch (SODataV4_DataServiceException *ex){
        NSLog(@"[LOAD CONNECTION]Exception occured during odata operation ex: %@", ex);
        XCTFail(@"[LOAD CONNECTION]Exception occured during odata operation ex: %@", ex);


Use applications to delete Connection object. If this succeeds your connection on the server will be deleted (a.k.a. registration is deleted).

    @try {
        [self.applications deleteEntity:connection];
    } @catch (SODataV4_DataServiceException *ex){
        NSLog(@"[DELETE CONNECTION]Exception occured during odata operation ex: %@", ex);
        XCTFail(@"[DELETE CONNECTION]Exception occured during odata operation ex: %@", ex);