Development environment: Eclipse Luna, SAPUI5 toolkit Eclipse plugin (download from SAP website)
Operating environment: Eclipse + Tomcat
OData Environment: Free NetWeaver Gateway-based test OData service provided by SAP on the public web
Code Description:
The first Test
Sserviceurl = "http://sapes1.sapdevcenter.com:8080/SAP/OPU/ODATA/IWFND/RMTSAMPLEFLIGHT/";
Found in Chrome, SAPUI5 will request an options (not get,post) HTTP request,/sap/opu/odata/iwfnd/rmtsampleflight/$metadata
To sapes1.sapdevcenter.com:8080, but did not put the user name password in the authentication HTTP header and submitted to sapes1.sapdevcenter.com : 8080,sapes1.sapdevcenter.com:8080 's answer is 401 not authenticated.
Sserviceurl = "http://services.odata.org/V4/Northwind/Northwind.svc/";
Found in Chrome, SAPUI5 will request an options (not get,post) HTTP request,/v4/northwind/northwind.svc/$metadata
To services.odata.org, Services.odata.org's answer is not implemented.
Well, the reason for the two error is actually the same, the search on the bing.com, https://scn.sap.com/thread/3367409 explained: "preflighted" requests first send an HTTP OPTIONS request header to the resource of the other domain, in order to determine whether the actual request was safe to SE nd. Cross-site Requests is preflighted like this since they may has implications to user data
Workaround:
Use the SAPUI5 built-in proxy feature to access the Cross-site cross-site OData service.
Sserviceurl = "proxy/http/sapes1.sapdevcenter.com:8080/sap/opu/odata/iwfnd/rmtsampleflight/";
The complete code is as follows:
<!
DOCTYPE html>