on 07-03-2013 10:22 PM
Hello everyone,
I am currently testing a mobile app using HTML5 in eclipse using the official SAPUI5 development kit. I almost have it working fully . Anyways, basically this program takes a external ODATA service and displays the data from it (product listing). It works inside my Eclipse environment preview but when i open it on my android phone (apk or local html file) there's an http data error ("Server error: HTTP request failed -" ) and no data is displayed. I have checked this webapp on my ipad (accessing localhost connection while the project is running in preview inside eclipse as well as my phone) and it shows the app but not the data (no error messages pop up). I believe I have it narrowed down to an issue this code in bold:
// data access
function getServiceUrl(sServiceUrl) {
var sOrigin = window.location.protocol + "//" + window.location.hostname
+ (window.location.port ? ":" + window.location.port : "");
if (!jQuery.sap.startsWith(sServiceUrl, sOrigin)) {
return "proxy/" + sServiceUrl.replace("://", "/");
} else {
return sServiceUrl.substring(sOrigin.length);
}
};
If i'm not mistaken this binds the public ODATA service to be used locally within the SAP network. I have tried a few things and still haven't had any luck. I will include the full code and a couple screenshots as attachments.
Any help would be greatly appreciated!
Thanks!
Hi Nader,
I agree with Simon about the CORS issue. With the conding above, you already get around this issues by using the SimpleProxyServlet. But this allows only "local" testing as described here:
https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/TestingInEclipse.html
So as long as you are testing with a browser on your computer, you should be fine. If you access the app from a different computer or mobile device, the SimpleProxyServlet will not work. This is described in the Security Guide posted by Simon:
Proxy Servlet (Java)
SAPUI5 is providing a SimpleProxyServlet. This proxy servlet can be used on a local server only for local requests to access data from other domains. This is useful to avoid cross domain issues when fetching data from another domain for testing purposes. Also for the SAPUI5 tools this is required since the local testing needs to access data from the remote ABAP server. Due to security reasons this proxy servlet is limited to localhost usage only and cannot be used by requests from other domains.
You can check http://scn.sap.com/community/developer-center/front-end/blog/2013/06/29/solving-same-origin-policy-i... how to get this solved.
Regards, Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Am still facing the same problem, I am able to access it through eclipse and tomcat on my pc, but when I run on emulator or deploy on android device I get www/proxy cannot be taken and If I I remove proxy I get web.response url error. In spite following all the blogs I am stuck in the situation. If any one have better solution please share.
Thank You in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nader,
That bit of code is checking the origin of the service URL. You are probably hitting the CORS issue - this is documented in the SAPUI5 here: https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/SecurityGuide.html
If the origin of your SAPUI5 app and the origin of the Service you are calling is different it tries to use the built in proxy. Is your app and the service coming from the same source/origin?
Hth,
Simon
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.