Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3184

OData Offline

$
0
0

Hi,

 

we are trying to get OData work offline. It works fine online, but we get exception on oDataStore.Open. It stops with "Unknown network error occured" or in Windows "Exception calling native with command :: OData :: openOfflineStore ::exception=TypeError: Die Eigenschaft "OfflineStore" eines undefinierten oder Nullverweises kann nicht abgerufen werden." But there is no error for createOfflineStore.

 

Sample code:


    var data = {

         languageID: getLanguageId(),

         hostName: "localhost", // host

         port: 8090, // port

         odataOnline: "/odata", // serviceRoot online requests

         odataOffline: "/odata_offline", // serviceRoot offline requests

         odataOfflineRequests: { // offline requests: definingRequests

             "LGNTINITAnrede_ODataVIEW" : "/LGNTINITAnrede_ODataVIEW"

         }

     };

     var getODataStore = function (complete, error) {

         Log.call(Log.l.trace, "appSettings.");

         var deferred = $q.defer();

         if (oDataStore) {

             Log.print(Log.l.trace, "oDataStore already opened");

             complete(oDataStore);

             deferred.resolve();

         } else if (sap && sap.OData &&

                     typeof sap.OData.createOfflineStore === "function") {

             window.setTimeout(function () {

                 Log.call(Log.l.trace, "appSettings.getODataStore.setTimeout");

                 var properties = {

                     name: "LeadSuccess",

                     host: data.hostName,

                     port: data.port,

                     serviceRoot: data.odataOffline,

                     definingRequests: data.odataOfflineRequests

                 }

                 oDataStore = sap.OData.createOfflineStore(properties);

                 if (oDataStore &&

                     typeof oDataStore.open === "function") {

                     Log.print(Log.l.trace, "createOfflineStore success! calling oDataStore.open()");

                     oDataStore.open(function () {

                         Log.call(Log.l.trace, "appSettings.oDataStore.open", "success!");

                         Log.print(Log.l.trace, "applyHttpClient() calling...");

                         sap.OData.applyHttpClient();

                         Log.print(Log.l.trace, "applyHttpClient() returned");

                         complete(oDataStore);

                         deferred.resolve();

                         Log.ret(Log.l.trace);

                     }, function (e) {

                         Log.call(Log.l.error, "appSettings.oDataStore.open", "oDataStore.open() failed!");

                         if (typeof e === "string") {

                             error({ status: 500, statusText: "open offline store failed with error:\r\n" + e });

                         } else {

                             error(e);

                         }

                         deferred.reject();

                         Log.ret(Log.l.error);

                     });

                 } else {

                     Log.print(Log.l.error, "createOfflineStore() failed!");

                     error({ status: 500, statusText: "Creating offline store failed" });

                     deferred.reject();

                 }

                 Log.ret(Log.l.trace);

             });

         } else {

             Log.print(Log.l.error, "sap.OData missing!");

             error({ status: 501, statusText: "OData offline store functionality not implemented" });

             deferred.reject();

         }

         Log.ret(Log.l.trace);

         return deferred.promise;

     };

 

thanks for help or suggestions

 

M. Marek


Viewing all articles
Browse latest Browse all 3184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>