Skip to content

SMP Client - Using ODataOnlineCore library to connect to SMP Server

In order to efficiently exercise SMP Server OData service we would like to firs 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 SMPClient 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 -java com.example.myapp.smpclient

This should have created an XS file.

Generating Java proxy classes from XS script file

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

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

This should generate a set of Java files that you need to add to your Android project.


  1. Clients must create 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.

    final UsernamePasswordToken token = new UsernamePasswordToken("userName","password");
    HttpConversationManager conversationManager = new CommonAuthFlowsConfigurator(getContext()).
    supportBasicAuthUsing(new UsernamePasswordProvider() {
        public Object onCredentialsNeededUpfront(ISendEvent event) { return token; }
        public Object onCredentialsNeededForChallenge(IReceiveEvent event) { return token; }
    }).configure(new HttpConversationManager(getContext()));
  2. Create SmpClient 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"

    SDKHttpHandler sdkHttpHandler = new SDKHttpHandler(getContext(), conversationManager);
    OnlineODataProvider registrationProvider = new OnlineODataProvider("SmpClient",
    SmpClient smpClient = new SmpClient(registrationProvider);
  3. Use SmpClient to create a new connection. For creating connection only one property is relevant, the DeviceType must be set to “Android”

    Connection newConnection = new Connection();


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.

Boolean passwordPolicyEnabled = newConnection.getPasswordPolicyEnabled();
Boolean passwordPolicyDefaultPasswordAllowed = newConnection.getPasswordPolicyDefaultPasswordAllowed();
Boolean passwordPolicyFingerprintEnabled = newConnection.getPasswordPolicyFingerprintEnabled();
String androidGcmSenderId = newConnection.getAndroidGcmSenderId();

Use the application service

In order to use a service the client must use its own generated proxy classes. Please note when configure the proxy service the same HttpConversationManager MUST be used in order to reach the service. By default the URL of application service looks like this: "https://serverHost:serverPort/yourApplicationID".

SDKHttpHandler sdkHttpHandler = new SDKHttpHandler(getContext(), conversationManager);
OnlineODataProvider serviceProvider = new OnlineODataProvider("flightService","https://serverHost:serverPort/yourApplicationID");
FlightService flightService = new FlightService(serviceProvider);


Use SmpClient to delete Connection