Skip to content

Using ODataOnlineCore library to connect to SMP Server

In order to efficiently exercise the SMP Server OData service, you first need to generate a 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 starts to use a service configured in an SMP server, the application must be registered to that server. The 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 BTP Platform.

Generating Proxy Classes

SMP SDK comes with pre-generated OData proxy classes, which comprise a convenience framework. It contains only generated code. In spite of our best efforts to update this library as often as possible, you may need to regenerate the content for your application.

Collecting $Metadata XML from the SMP Server

In order to generate the OData proxy classes, you will need to download the $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 the 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 will create an XS file.

Compiling ObjectiveC Proxy Classes from an XS Script File

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

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

This generates the set of Objective C files that you need to add to your Xcode project.


  1. Clients must create an HTTPConversationManager object and configure it according to the authentication method of the server. The example in this document uses basic authentication. See the HttpConversation Developer Guide for details about other authentication options, such as SAML2 or OAuth2.
self.manager = [HttpConversationManager new];
//add here configuration code as per HttpConversationManager developer guide.
  1. Create the 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 SMPCLient to create a new connection. When creating connections, 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 occurred during odata operation ex: %@", ex);

Application Settings

After a Connection is successfully created, the server responds with application settings configured in the server and the Connection object will contain application settings relevant for the application. Please refer to the SMP documentation for information regarding the 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 bound 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 SMPClient to delete a Connection object. If successful, your connection on the server will be deleted (the 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);