cancel
Showing results for 
Search instead for 
Did you mean: 

ODataOfflineException Android SMP 3.0

Former Member
0 Kudos

Hi!

I´m trying to open an OfflineStore (using Android, SMP 3.0 SP04 and SDK 3.0 SP05) but I´m getting this error  com.sap.smp.client.odata.offline.ODataOfflineException: [-10060] An error occurred while performing a synchronization.  Reason: -1305 (MOBILINK_COMMUNICATIONS_ERROR) %1:24 %2: %3:336134278.

In this link I´ve found what it could be a solution http://scn.sap.com/thread/3470776 but it´s oriented to SUP and I´ve couldn´t find how to create the connection profile, neither the synchronization profile in SMP 3.0. My code looks like this:

try {

  ODataOfflineStore.globalInit();

  LogonCoreContext lgCtx = LogonCore.getInstance().getLogonContext();

  lgCtx.setAppEndPointUrl("https://xxx.xxx.local:xxxx/gateway/odata/XXXXX/XXXXXXX/");

  lgCtx.setHost("https://xxx.xxx.local");

  lgCtx.setPort(xxxx);

  lgCtx.setHttps(true);

  lgCtx.setConnId(Globales.getappCID());

  String endPointURL = lgCtx.getAppEndPointUrl();

  URL url = new URL(endPointURL);

  ODataOfflineStoreOptions options = new ODataOfflineStoreOptions();

  options.host = url.getHost();

  options.port = String.valueOf(url.getPort());

  options.enableHTTPS = lgCtx.isHttps();

  options.serviceRoot= endPointURL;

  options.extraStreamParms = "custom_header=Authorization:Basic " + ";custom_header=X-SMP-APPCID:" +  Globales.getappCID() + ";";

  String appConnID = lgCtx.getConnId();

  options.customHeaders.put("X-SMP-APPCID", appConnID);

  options.enableRepeatableRequests = false;

  options.storeName="SMP3";

  options.definingRequests.put("reg1","test");

  offlineStore = new ODataOfflineStore(context);

  offlineStore.openStoreSync(options);------> Exception here

  TraceLog.d("openOfflineStore: library version "+ ODataOfflineStore.libraryVersion());

} catch (ODataException e) {

  e.printStackTrace();

}

Thank you in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

miguel_lnavarro
Explorer
0 Kudos

Hi, could you resolve the error? i have the same problem

Former Member
0 Kudos

Hi Mohamed/Miguel,

If am not wrong the screenshot shows that you are using MAFLogon library.

In this case you have to enter your server IP address and port is 8080. Because the gateway service you will register on SMP Server. Through SMP server you are trying to fetch data.

So smp server will take care of this.

Regards

Sathiya

miguel_lnavarro
Explorer
0 Kudos

Hi sathiya, my problem is the excepción, the same error that roxxy

Regards

claudiapacheco
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Roxxy,

Hope one of the following solutions helps,

Solution 1

I think you are missing the line of codes where you pass the credentials to the offline store, or at least I don't see it in the code snippet you posted.


Just for testing purposes try the following lines. Please note these offline store options properties are deprecated and this is not the recommended way to assign the credentials. It will help me troubleshoot your problem.

  options.password = "xxxx";

  options.username = "xxxx";

if it works with this additional information, then you need to add one of the following options:


Option 1: Are you using MAFLogon component to on-board your user?

In the blog I wrote I included these lines and I don't see them in your code:


//The logon configurator uses the information obtained in the registration

// (i.e endpoint URL, login, etc ) to configure the conversation manager

IManagerConfigurator configurator =

                     LogonUIFacade.getInstance().getLogonConfigurator(context);

HttpConversationManager manager = new HttpConversationManager(context);

configurator.configure(manager);

options.conversationManager = manager;


Option 2: If you are not using MAF Logon component to on-board your user?

you will need to add something like this, (code may be incomplete)


CredentialsProvider credProvider = CredentialsProvider.getInstance(lgCtx);

HttpConversationManager manager = new CommonAuthFlowsConfigurator(context).

supportBasicAuthUsing(credProvider).configure(new HttpConversationManager(context));

options.conversationManager = manager;


In the above code snippet, the CredentialsProvider class implements UsernamePasswordProvider interface.

The UsernamePasswordProvider Interface allows you to supply the credentials to authenticate with SAP Gateway when the store needs them


Solution 2:

Remember to work with the latest patches as mentioned in this discussion


Solution 3:

You can find Android sample codes in https://github.com/SAP/sap_mobile_native_android

There are 2 branches: master (incomplete projects) and solution (complete)

These projects are meant to help developers getting started with the SMP OData SDK.

You can find the associated How To.. guides in the following links

Try any of these options and let us know how it went.

Best regards,

Claudia


PS: Thanks for including me in the discussion

Former Member
0 Kudos

Hi again!

Sorry the delay, here my answers:

- Solution 1:

I tried adding the offline store options properties but it didn't work.

options.password = "xxxx";

options.username = "xxxx";

Option 1: The MAFLogon configurator in line LogonUIFacade.getInstance().getLogonConfigurator(this) is throwing an NullPointerException, don't get it why, I searched on google finding nothing about it. The complete code with it:

try {

  Context context = this;

  ODataOfflineStore.globalInit();

  LogonCoreContext lgCtx = LogonCore.getInstance().getLogonContext();

  lgCtx.setAppEndPointUrl("https://xxx.xxx.local:xxxx/gateway/odata/XXXXX/XXXXXXX/");

  lgCtx.setHost("https://xxx.xxx.local");

  lgCtx.setPort(xxxx);

  lgCtx.setHttps(true);

  lgCtx.setConnId(Globales.getappCID());

  String endPointURL = lgCtx.getAppEndPointUrl();

  URL url = new URL(endPointURL);

  ODataOfflineStoreOptions options = new ODataOfflineStoreOptions();

  options.host = url.getHost();

  options.port = String.valueOf(url.getPort());

  options.enableHTTPS = lgCtx.isHttps();

  options.serviceRoot= endPointURL;

  options.extraStreamParms = "custom_header=Authorization:Basic " + ";custom_header=X-SMP-APPCID:" +  Globales.getappCID() + ";";

  IManagerConfigurator configurator = logonUIFacade.getLogonConfigurator(context);

  HttpConversationManager manager = new HttpConversationManager(context);

  configurator.configure(manager);

  options.conversationManager = manager;

  String appConnID = lgCtx.getConnId();

  options.customHeaders.put("X-SMP-APPCID", appConnID);

  options.enableRepeatableRequests = false;

  options.storeName="SMP3";

  options.definingRequests.put("reg1","test");

  offlineStore = new ODataOfflineStore(context);

  offlineStore.openStoreSync(options);

  TraceLog.d("openOfflineStore: library version "+ ODataOfflineStore.libraryVersion());

} catch (ODataException e) {

  e.printStackTrace();

}

- Solution 2:

It was updated from PL01 to the latest patch PL05 and the exception keeps being throwed.

- Solution 3:

Following the tutorial How To...Consume OData Services in Offline Mode (Android), I used the Android sample in order to know how it works. Once it's executed, the application requests the server URL for this sample (Appendix D), therefore I cannot look further. Do you know the service's information so I can debug the sample code?.

In this video: https://www.youtube.com/watch?v=t_vsmeBAjGM  I can see the ip but not the credentials to log in and debug it, it may be helpful to figure out what I am missing or doing wrong.

Thank you in advance

claudiapacheco
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Roxxy,

Re: solution 1, option 1

I've seen the Logon Configurator throws NullPointerException when the project does use the MAF Logon component UI screens.

Q1: Could it be possible that you are not using the MAF Logon component as indicated in this guide How To... Enable user On-boarding using MAF Logon with Template Project (Android)?

Q2: Is your user successfully on-boarded and has a valid Application connection ID

Q3: Have you tried the option 2?

Re: solution 3

The exercises assume you are using your own servers. If you have access to an SAP Gateway, then you can use the RMTSAMPLEFLIGHT service.

These are the basic assumption for the How To guides.

1. Application ID: You have configured an application in SMP 3.0 called "com.sap.flight"

2. Backend Endpoint URL: The SMP backend URL must point to the RMTSAMPLEFLIGHT service that is available in all SAP Gateway installations (i.e http://gateway server:gateway port/sap/opu/odata/iwfnd/RMTSAMPLEFLIGHT/)

Troubleshooting Steps

- Go to the SMP Management cockpit

- Go to Logs > Settings

- Select the Offline component, change the Log Level to info

- Run the app again and check the server logs. If you see something strange, please post it.

Regards,

Former Member
0 Kudos

Hi Claudia,

I was trying to test the example that you explain in the How to guides but I have the same problem that Roxxy because when I execute the App it requests me the Server URL(Appendix D). I really don't understand if I have to install the RMTSAMPLEFLIGTH into my server, or I can use your server (public server). In case that I have to use my own server, can you tell me  Where can I find the installer and data source to do it?. in case that I can test with your environment, Could you please tell me the information to connect?. I'm stuck in this test and we're really hurry because we depend to this test to move on in the project.

I really appreciate your help,

thanks a lot.

claudiapacheco
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Cesar,

The RMTSAMPLEFLIGHT is available by default in SAP Gateway Server. However, the service may not be activated. If you have SAP Gateway server you can activate the RMTSAMPLEFLIGHT in the transaction /IWFND/MAINT_SERVICE.


Please check the help.sap site to follow instructions on how to activate this service

2.1 Activate the Service - SAP NetWeaver Gateway - SAP Library


Another way to check if the service is available is to open an Internet browser and type the service URL(i.e http://<gateway-server>:<gateway-port>/sap/opu/odata/iwfnd/RMTSAMPLEFLIGHT/). It should prompt for your gateway login and password.


Once you are authenticated, the service document xml information should appear

Hope this helps

Former Member
0 Kudos

Hi,

The same issue am also facing.Is there any solution for this.Am developing one native application the registeration done successfully but how can i store the data for offline data use.

Regards

Sathiya

Former Member
0 Kudos

Excuse me Claudia,

What's the server url value should I input when using SAP NW gateway. Also, what's the port number. My credential to ES1 is OK. Is there any thing else not stated in your how to guide?

Thanks,

Mohamed.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Have a look at this blog

Here, you will get all required information.

Former Member
0 Kudos

Thank you Jitendra Kansal , let me check it out.

Former Member
0 Kudos

Jitendra Kansal I have read the link and my code is exact as it says, also the libraries... but I'm still getting the exception.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Maybe  can help you on this.

Former Member
0 Kudos

I already wrote her, thank you!