on 07-15-2015 3:53 PM
Hi,
I am facing one issue regarding Accessing different domain OData web service. in SAP UI5.
Currently what i am doing is shown below :
var oModel = new sap.ui.model.json.JSONModel();
var aData = jQuery.ajax({
type : "GET",
contentType : "application/json",
url : "http://domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet",
dataType : "jsonp",
success : function(data,textStatus, jqXHR) {
oModel.setData({modelData : data});
alert("success to post");
}
});
But i am getting below mentioned error:
XMLHttpRequest cannot load http://domain name::8006/sap/opu/odata/SAP/ZR_SRV/YR_CODESet()?$format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:56167' is therefore not allowed access. The response had HTTP status code 405.
sap-ui-core.js:80 2015-07-15 20:15:14 The following problem occurred: HTTP request failed0,, -
Please provide me some helpful solution for that as i am stuck in very urgent deliverable assignment.Helpful answere will be rewarded.
Thanks,
Vinay Sharma
try
url : "proxy/http/domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet",
and it showing you are testing in locally. which server you are using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Santhosh,
I am testing in locally . After using same url : "proxy/http/domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet" getting same error message, Could you please provide some suitable solution step by step to test on locally.
This is oData model not a JSONModel.
Write like this.
var oModel = new sap.ui.model.odata.ODataModel();
var aData = jQuery.ajax({
type : "GET",
contentType : "application/xml",
url : "http://domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet",
dataType : "jsonp",
success : function(data,textStatus, jqXHR) {
oModel.setData({modelData : data});
alert("success to post");
}
});
Also write like this.
url : "proxy/http/domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet",
try,
$.ajax({
url :"proxy/http/domain name:port name/sap/opu/odata/SAP/ZR_SRV/YR_CODESet",
jsonpCallback : 'getJSON',
contentType : "application/json",
dataType : 'json',
async : false,
success : function(data, textStatus, jqXHR)
{
var oModel1 = new sap.ui.model.json.JSONModel();
oModel1.setData(data);
console.log(oModel1);
var aData = oModel1.getProperty("/d/results");
console.log(aData);
},
error : function (err){
},
});
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.