Setting Up Application Properties

The Application instance contains the information and authentication credentials needed to register and connect to the SAP Mobile Server.

The following code illustrates how to set up the minimum required fields:
// Initialize Application settings
Application app = Application.getInstance();

// The identifier has to match the application ID deployed to the SAP Mobile Server
app.setApplicationIdentifier("SUP101");
// Set the android.content.Context for the application
app.setApplicationContext(context); // context is the android.content.Context

// ConnectionProperties has the infomation needed to register
// and connect to SAP Mobile Server
ConnectionProperties connProps = app.getConnectionProperties();
connProps.setServerName("server.mycompany.com");
// if you are using Relay Server, then use the correct port number for the Relay Server.
// if connecting using http without a relay server, use the messaging administration port, by default 5001.
// if connecting using https without a relay server, then use a new port for https, for example 9001.
connProps.setPortNumber(5001);

// if connecting using https without a relay server, set the network protocol
connProps.setNetworkProtocol("https"); 

//  Set FarmId and UrlSuffix when connecting through the Relay Server. 

// Provide user credentials
LoginCredentials loginCred = new LoginCredentials("supAdmin", "supPwd");
connProps.setLoginCredentials(loginCred);

// Initialize generated package database class with this Application instance
SMP101DB.setApplication(app);
Note: setApplicationIdentifier and setApplicationContext must be called in the user interface thread.

If you are using a Relay Server, specify the connection as follows:

// specify Relay Server Host
connProps.setServerName("relayserver.mycompany.com");
// specify Relay Server Port (port 80 by default)
connProps.setPortNumber(80);
// specify the Relay Server MBS Farm, for example MBS_Farm
connProps.setFarmId("MBS_FARM");

Optionally, you can specify the Relay Server URL suffix.

Using a Reverse Proxy for Object API Applications

The Object API application communicates with SAP Mobile Server through two ports:
  1. Application registration (default 5001)
  2. Application synchronization (default 2480)
The SAP Mobile Server administrator configures two ports with each port serving one SAP Mobile Server port, so that:
  • The root context of http://reverseProxy:5001 maps to http://server-name:5001
  • The root context of http://reverseProxy:2480 maps to http://server-name:2480
Set Object API application connection properties just as you would to directly connect to SAP Mobile Server.
The SAP Mobile Server administrator configures two contexts for one SAP Mobile Server port, so that:
  • The "/smp/message" context of http://reverseProxy:8080 maps to http://server-name:5001
  • The "/smp/mobilink" context of http://reverseProxy:8080 maps to http://server-name:2480
Set the URL suffix for the Object API application to "/smp/message" for registering applications and "/smp/mobilink" for synchronization, just as you would if connecting to SAP Mobile Server through a Relay Server which is not installed at the default location. The difference is that you do not include a FarmId for the reverse proxy.
Note: When using an Apache server as a reverse proxy without SAP Hosted Relay Server to proxy Object API Applications against SAP Mobile Server, if a custom URL suffix is used, clients should specify a custom URL suffix including a trailing forward slash "/". For example, "/myApp/" instead of "/myApp". If not, the client may report connection failures.
Related reference
Application APIs