Hello everyone
I am struggling with a problem for which I haven't found a solution over several weeks.
I am trying to create an offline app where it is possible to create new entries. The app is a simple javascript based Kapsel offline app that has been created with WebIDE and Hybrid Application Toolkit. The keys for new entries are generated by the server when the data offline is synced with the backend. While creating the entries I am using temporary keys so that the entries have a key while the app is offline.
The problem is that I always receive an error message when my app tries to sync data back to the server after I have created a new record. In that case I get the message "Failed to flush data back to the server". The javascript console shows the additional internal error message "An unknown network error occurred." There are no other error messages about the sync process - also not if I use logcat from the Android developer tools to see all the messages that are generated on the device.
In the logs of HCPms I only get this:
#2.0#2016-02-24 11:17:59 AM#WARNING#Offline####1456312679394001#a7cf4e82-9872-410f-8e7c-46dfad330bf4#de.itaricon.apps.demo.maintenance#MobilinkAppcidFilter:doFilter########563#####Completed Mobilink adapter request. Response code is >= 400. appcid: 465293ea-9d2f-4548-812f-331db510f987 , requestURI: /MobiLink/ServletAsync, method POST, status 400 time since handoff(ms): 1#
However, when I do a trace of the HTTP traffic that goes through the cloud connector towards towards my SAP backend and back then I see no errors whatsoever. When a new record is created then the backend server responds with a 201 CREATED return code. Nevertheless, HCMms seems to have a problem somehow as is shown by the log entry.
Because the client receives an error message from HCPms, it continues to consider the new entry as not yet synced and will try to create it again each time when a sync with the backend is triggered by the user. In this way the entry is created again in the backend with each sync.
The simplest test application that I used is was created with the Master Detail Kaspsel Offline Application template in WebIDE. I simply clicked through the wizard and packaged the application. The OData service is simple: It has short keys and all fields of the entity type in question are character-typed. There is no problem to use the same application as online app in the browser.
The creation of items on the client is done like this (straight sample code from the webide template):
var model = this.getView().getModel(); | |||
var newEntry = model.createEntry(sEntityPath); | |||
this.switchMode("create"); | |||
model.newEntryContext = newEntry; | |||
//clean bounded data object | |||
oView.unbindObject(); | |||
//now set new binding context | |||
oView.setBindingContext(newEntry); | |||
Alternatively I also tried this to assign a temporary key on the client (the key field is defined as char32):
var model = this.getView().getModel(); | |||
var newEntry = model.createEntry(sEntityPath, {id: 'id-' + Date.now().toString()}); | |||
this.switchMode("create"); | |||
model.newEntryContext = newEntry; | |||
//clean bounded data object | |||
oView.unbindObject(); | |||
//now set new binding context | |||
oView.setBindingContext(newEntry); | |||
The syncing code with the backend in devlogon.js and devadmin.jsis competely unchanged.
Does anyone have an idea what could be the problem? The weird thing is that the server has no problem to create the entries and responds with return code 201 and yet the HCPms has this cryptic log entry about a return code >=400.
Any help and any suggestions on how to debug this problem further or solve it are greatly appreciated.
Thanks a lot
Christian