Skip to Content
0

Load multiple service as a mock service in sapui5 app - hcp ?

Jun 29, 2017 at 04:19 PM

57

avatar image

Hi Experts,

I have a requirement where I have to load multiple mock services into my application(multiple metadata files need to load).

Please check the code below. I tried to load multiple services but that only loads the first oMockServer.start(); function then it gives a library error.

sap.ui.define([
	"sap/ui/core/util/MockServer"
], function(MockServer) {
	"use strict";
	return {
		init: function() {
			// create
			var oMockServer = new MockServer({
				rootUri: "/destinations/ABC/V2/ABC/ABC.svc/"
			});
			var oUriParameters = jQuery.sap.getUriParameters();
			// configure
			MockServer.config({
				autoRespond: true,
				autoRespondAfter: oUriParameters.get("serverDelay") || 1000
			});
			// simulate
			var sPath = "model/localService/test1";
			oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
			// start
			oMockServer.start();
			
			// simulate
			var sPath = "model/localService/test2";
			oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
			// start
			oMockServer.start();
		}
	};
});
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers