Skip to Content
0

Mock Server Configuration problem

May 08 at 01:17 PM

75

avatar image

Dear All,

I'm trying to configure Mock server using "Step 27: Mock Server Configuration" documentation. When I run my project in webide then I get below errors. I didn't implement controller logic yet but just wants to display my first root view with mock data.

Why I am seeing $count and $skip queries failing? Why I am seeing those queries when I run the app with mock data?

image-14.png (141.2 kB)
image-14.png (141.2 kB)
image-15.png (135.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member
May 10 at 12:58 PM
0

Are you starting the application with mockServer.html in the "webIDE", because I just tested one of my own Mock servers and there is no GET request involved? The json files loaded and the mock data is read from there.

Note that the request in your console log is for WorklistSet but in the project folders you only have Worklist.json.

So even if mock application run configuration used there is no file WorklistSet.json

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member
May 08 at 02:30 PM
0

Could you copy the content of the mockServer.html, as some of the namespaces destinations have to be adjusted compared to the original index.html?

Such as:

data-sap-ui-resourceroots='{"projectname": "../"}

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the quick response. Please find the code below. Also, in manifest.json, I mentioned the localuri like below. I don't have the backend service built and hence I am using some dummy value.

I couldn't attach the files due file type restriction and hence pasting the code below.

mockServer.html

<!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8"> <title>Awards Mock Test</title> <script id="sap-ui-bootstrap" src="../../resources/sap-ui-core.js" data-sap-ui-theme="sap_belize" data-sap-ui-libs="sap.m" data-sap-ui-compatVersion="edge" data-sap-ui-preload="async" data-sap-ui-resourceroots='{ "com.orpic.mobility.HRAwards": "../" }'></script> <script> sap.ui.getCore().attachInit(function () { sap.ui.require([ "com/orpic/mobility/HRAwards/localService/mockserver", "sap/m/Shell", "sap/ui/core/ComponentContainer" ], function (mockserver, Shell, ComponentContainer) { mockserver.init(); new Shell({ app : new ComponentContainer({ name : "com.orpic.mobility.HRAwards", settings : { id : "HRAwards" } }) }).placeAt("content"); }); }); </script> </head> <body id="content"></body> </html>

manifest.json file

{ "_version": "1.8.0", "sap.app": { "_version": "1.3.0", "id": "com.orpic.mobility.HRAwards", "type": "application", "i18n": "i18n/i18n.properties", "applicationVersion": { "version": "1.2.2" }, "dataSources": { "local": { "uri": "/here/goes/your/serviceUrl/local/", "type": "OData", "settings": { "odataVersion": "2.0", "localUri": "localService/metadata.xml" } } }, "title": "{{appTitle}}", "description": "{{appDescription}}", "ach": "ach", "resources": "resources.json", "sourceTemplate": { "id": "ui5template.basicSAPUI5ApplicationProject", "version": "1.32.0" } }, "sap.ui": { "_version": "1.3.0", "technology": "UI5", "icons": { "icon": "", "favIcon": "", "phone": "", "phone@2": "", "tablet": "", "tablet@2": "" }, "deviceTypes": { "desktop": true, "tablet": true, "phone": true } }, "sap.ui5": { "_version": "1.3.0", "rootView": { "viewName": "com.orpic.mobility.HRAwards.view.Worklist", "type": "XML", "async": true }, "dependencies": { "minUI5Version": "1.50.0", "libs": { "sap.ui.core": {}, "sap.m": {}, "sap.ui.layout": {} } }, "contentDensities": { "compact": true, "cozy": true }, "models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "uri": "i18n/i18n.properties" }, "": { "dataSource": "local", "type": "sap.ui.model.odata.v2.ODataModel", "settings": { "loadMetadataAsync": false, "json": true, "bJSON": true, "defaultBindingMode": "TwoWay", "useBatch": true, "refreshAfterChange": false, "disableHeadRequestForToken": true } } }, "resources": { "css": [] } } }

0
Former Member

The mock server seems to be set properly.

The problem is with the "rootURI" of your service or with the service itself.

Parameter "rootURI" in mockServer.js has to be exactly the same as the URI that is defined for the data source in the "manifest.json" descriptor file. I guess this is fine because that URI is called in the console log, but there is no service available in that path.

Did you map the mock data properly in mockserver.js (path and namespace correct)? You can console log the "sPath" to make sure it points to the right directory where metadata.xml is, then delete that line later.

var sPath = jQuery.sap.getModulePath("sap.ui.demo.walkthrough.localService"); 
console.log(sPath);
oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
0

Hi Miklos,

It is bit strange that I didn't receive any e-mail notification of your comment. I saw it now.

My mockserver.js contains rootUri like below. the path is dummy as I don't have any real service which is working in backend. This matched with manifest.json as well.

var oMockServer = new MockServer({
rootUri: "/here/goes/your/serviceUrl/local/"
});

console log for sPath is "../localService " and seems ookay until it reaches metadata.xml and mockdata folder.

image-2.png (50.1 kB)
0

I am attaching the latest console log.

sPath value is ../localService

image-3.png (48.9 kB)
0

Yes. I renamed the json file already today. I'm using mockServer.html to run the application. I am facing different error now and looks like my descriptor is wrong. Could you guide me to know the problem as I'm novice in this area.

image-4.png (51.2 kB)
image-4.png (51.2 kB)
0

My descriptor is given below.

{
"_version": "1.8.0",
"sap.app": {
"_version": "1.3.0",
"id": "com.orpic.mobility.HRAwards",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.2.2"
},
"dataSources": {
"local": {
"uri": "/here/goes/your/serviceUrl/local/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"ach": "ach",
"resources": "resources.json",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.32.0"
}
},
"sap.ui": {
"_version": "1.3.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"_version": "1.3.0",
"rootView": {
"viewName": "Worklist",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.50.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"": {
"dataSource": "local",
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"loadMetadataAsync": false,
"json": true,
"bJSON": true,
"defaultBindingMode": "TwoWay",
"useBatch": true,
"refreshAfterChange": false,
"disableHeadRequestForToken": true
}
}
},
"resources": {
"css": []
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "com.orpic.mobility.HRAwards.view",
"controlId": "HRAwards",
"clearTarget": false,
"controlAggregation": "pages",
"bypassed": {
"target": [
"Worklist"
]
}
},
"targets": {
"Worklist": {
"controlAggregation": "pages",
"viewName": "Worklist",
"viewId": "Worklist",
"viewLevel": 1,
"transition": "show"
}


},
"routes": [

{
"pattern": "",
"name": "default",
"target": [
"Worklist"
]
}

]
}
}
}

0
Former Member

The connection between routes and targets are the name attribute, therefore "targets.Worklist" should be "targets.default" or vice versa. Check out the Routing and Navigation.

The solution to the original question is the rename of the file is it not? If yes then mark that answer as accepted, and ask different problem in a new question. This helps the community to find solutions easier. If you put the URL of the new question in this question as a comment I am going to have a look.

0