SUP:通过中继服务器连接Android应用程序SAP-SUP

时间:2013-06-18 15:10:59

标签: android sup bapi

我是一名移动开发人员,现在正在开发一款连接到SAP后端的Android应用。

我需要从BAPI创建MBO并从这些BAPI中读取数据

我设法从BAPI_FLIGHT_GETLIST BAPI

创建了MBO

我将代码生成为Android代码,我创建了活动来读取此MBO中的数据

当我在Android设备上运行应用程序时,我在此行中得到以下错误

app.registerApplication(TIMEOUT);

任何人都可以帮我解决这个错误吗?

我不明白我做错了什么

MainActivity:

private static final int REQUEST_DETAIL = 99;
          private static String USERNAME = "*********";
          private static String PASSWORD = "**********";
          private static String HOST = "************";
          private static int PORT = 5001; // 2480
          private static int sync_port = 2480;
          private static int TIMEOUT = 600;
private GetFlightsListAdapter adapter;


@Override
          protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_main);
                    initializeApplication();
          }

private void initializeApplication() {

                      try {
                    // 1. App initialization
                       Application app = Application.getInstance();
                       app.setApplicationIdentifier("GetFlights");
                       app.setApplicationContext(MainActivity.this);
                       GetFlightsDB.setApplication(app);
                       GetFlightsDB.getSynchronizationProfile().setServerName(HOST);
                    // 2. Set connection properties
                       ConnectionProperties connProps = app.getConnectionProperties();
                       LoginCredentials loginCredentials = new LoginCredentials(USERNAME,PASSWORD);
                       connProps.setLoginCredentials(loginCredentials);
                       connProps.setServerName(HOST);
                       connProps.setPortNumber(PORT);
                      //3. App registration
                       if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED) {
                           app.registerApplication(TIMEOUT); // ERROR HAPPENS HERE <-----------
                       } else {
                           app.startConnection(TIMEOUT);
                       }
                       //4. Sync data          
                       if (!GetFlightsDB.isSynchronized("default")) {
                                 GetFlightsDB.disableChangeLog();
                                 GetFlightsDB.synchronize(); // Initial Synchronize
                           SynchronizationGroup sg = GetFlightsDB.getSynchronizationGroup("default");
                           sg.setEnableSIS(true);
                           sg.save();
                           GetFlightsDB.synchronize();
                       }
                       GetFlightsDB.enableChangeLog();
                   }

             finally {
                       Log.v("Finally", "Finally");
                   }


          }

错误

Caused by: com.sybase.mobile.ApplicationRuntimeException: Error: 558 Message: 'Could not connect to server. Verify Relay Server URL Template'
E/AndroidRuntime(273):           at com.sybase.mobile.Application.registerApplication(Application.java:409)
E/AndroidRuntime(273):           at com.example.getflightsnative.MainActivity.initializeApplication(MainActivity.java:84)

清单文件:

<uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
        <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />


        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.getflightsnative.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />


                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>


        <uses-sdk
            android:minSdkVersion="3"
            android:targetSdkVersion="7" >
        </uses-sdk>

1 个答案:

答案 0 :(得分:1)

要连接到中继服务器,您必须提供服务器场ID。

ConnectionProperties connProps = app.getConnectionProperties();
LoginCredentials loginCredentials = new    LoginCredentials(USERNAME,PASSWORD);
connProps.setLoginCredentials(loginCredentials);
connProps.setServerName(HOST);
connProps.setPortNumber(POST); port for relay server is 80
connProps.setUrlSuffix("/ias_relay_server/client/rs_client.dll/%cid%/tm");
connProps.setFarmId(FARMID); //provide MBS farm Id for registration. And sync will be      different