on 07-21-2014 11:35 AM
hi All,
I was trying to do one basic ODATA example which i got from the threads.
<!DOCTYPE html>
<html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>Table with OData Binding</title>
<script id='sap-ui-bootstrap' type='text/javascript'
src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table"
data-sap-ui-theme="sap_bluecrystal"></script>
<script>
// the root URL of the OData service - prefixed with a local URL to a proxy which forwards the request,
circumventing cross-domain restrictions
// IMPORTANT: this proxy must be available for the code example to run!
var url = "http://services.odata.org/Northwind/Northwind.svc";
// create an ODataModel from URL
var oModel = new sap.ui.model.odata.ODataModel(url, true);
var oTable = new sap.ui.table.Table("sampleTable");
oModel.read("/Customers",null,null,null,function(){
var metadata = oModel.getServiceMetadata();
var entityCustomerRef = metadata.dataServices.schema[0].entityType[2];
var listOfProperties = entityCustomerRef.property;
for ( var i = 0; i < listOfProperties.length; i++) {
oTable.addColumn(new sap.ui.table.Column().setLabel(
new sap.ui.commons.Label({
text : listOfProperties[i].name,
})).setTemplate(
new sap.ui.commons.TextField().bindProperty("value",
listOfProperties[i].name))) }
oTable.setModel(oModel); // set model to Table
oTable.bindRows("/Customers");
});
oTable.placeAt("content"); // place model onto UI
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body>
</html>
but when i try to execute the same it is not loading any data and showing the error as :
2Failed to load resource: the server responded with a status of 501 (Not Implemented) http://services.odata.org/Northwind/Northwind.svc/$metadata
XMLHttpRequest cannot load http://services.odata.org/Northwind/Northwind.svc/$metadata. Invalid HTTP status code 501 odata.html:1
But i can launch the url with metadata through browser..kindly help???
Hi,
I have 2 apps, one UI5 and XS.
The XS expose a oData Service and the UI5 consume it.
But I'm getting this error when the SapUI5 try to get the data from the XS app.
Can anyone help me to solve it?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
replace the following line in your code:
var url = "http/services.odata.org/Northwind/Northwind.svc";
with the following:
var url = "proxy/http/services.odata.org/Northwind/Northwind.svc";
It will either work fine or this error will be skipped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ranjit,
I think you didn't get my doubt clearly, I am able to connect url and create the table from the above code if i run this as a web application.
I am looking to create the same application as an android app, and for that purpose how should i proceed, if i directly convert this web app to android app it is not fetching the data from the url, so I hope there is some way of creating an odata consuming android app, I am looking for that solution.
Regards,
Arun
Hi,
try something like this JS Bin - Collaborative JavaScript Debugging</title> <link rel="icon" href="h...
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.