Search code examples
sapui5mockserver

SAPUI5 mock server


I have trouble getting the mock server to work. I have set up everything according to the SAPUI5 guide provided here, but when I launch the application using mock server ("/test/mockServer.html") it gives me error in console:

Uncaught (in promise) Object {message: "HTTP request failed", request: Object, response: Object, statusCode: 404, statusText: "Not Found"…}

What could be the problem? I have tryed simulating the service with mockDataUri or just with the metadata uri, but either way the result is the same. I also tried to run the mockServer.html from Web IDE, but it didn't change anything.

EDIT: it seems that the problem is about how to use the mock server not the server itself, because mock server contains data, but I can't get the data to model. Example:

// Create Mock Server
var oMockServer = new MockServer({
    rootUri: rootUri
});
...
oMockServer.getEntitySetData("Entity") // Returns generated mock data
...
// Create Model
var oModel = new sap.ui.model.odata.ODataModel(rootUri, true);
dataModel.read("Entity", null, null, true, function (oData, oResponse) {
    console.log(oData, oResponse);
}, function (oError) {
    console.log(oError); // logs Object {message: "HTTP request failed", request: Object, response: Object}
});

What could be the problem?


Solution

  • rootUri shouldn't contain "https:// this.kinof.url / myService /". Use only "/myService/" instead.