Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Walkthrough Tutorial: OData Service with MockServer

$
0
0

Hello Experts,

 

i am new to SAPUI5 and currently working through the Walkthrough Tutorial as described here: SAPUI5 SDK - Demo Kit

 

In "Step 26: Remote OData Service" you learn how to connect to a remote service via proxy servlet.

 

Per Tutorial the URI is described as follows:

 

Original OData URI
"config":{
 
"invoiceLocal":"/Invoices.json",
 
"invoiceRemote":"/proxy/http/services.odata.org/V2/Northwind/Northwind.svc/"

},

 

However testing my application I was not able to connect to the remote service in that way.

 

Error for URI /proxy/http/services.odata.org/V2/Northwind/Northwind.svc/

GET http://localhost:53399/proxy/http/services.odata.org/V2/Northwind/Northwind.svc/$metadata 404 (Not Found)

 

In order to connect to the remote service i had to change the URI excluding the initial '/':

 

Corrected OData URI
"config":{
 
"invoiceLocal":"/Invoices.json",
 
"invoiceRemote":"proxy/http/services.odata.org/V2/Northwind/Northwind.svc/"

},

 

In "Step 27: Mock Server and Automatic Model Instantiation" you now learn how to setup a MockServer, so you don't have to rely on the real service being available during your testing. There is a bunch of changes performed, but I am particularly struggling with the rootURI in new server.js:

 

server.js
// create
var oMockServer =newMockServer({
rootUri
:"/proxy/http/services.odata.org/V2/Northwind/Northwind.svc/"
});

 

Per the scenario you now have 2 files to run you application

- index.html: The real application using the actual web service

- indexTest.html: The test application using the MockServer

 

In order for the MockServer to work, i have to adjust my OData URI back to include the leading "/", however then my real service doesn't work. I also tried changing the MockServer URI to:

"proxy/http/services.odata.org/V2/Northwind/Northwind.svc"

- "http://services.odata.org/V2/Northwind/Northwind.svc"

 

but nothing seems to work. The MockServer is beeing ignored and the real service called instead.

 

Does anyone have an idea what might be wrong? Is my proxy servlet configured incorrectly and the true Service URL should be "/proxy/" or is "proxy/" the right notation and i have to fix something in my MockServer definition.

 

Greatly appreciate your help!

 

Regards,

Jan


Viewing all articles
Browse latest Browse all 6178

Trending Articles



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