OData.read无法在IE中工作(缺少标题,没有数据) - 适用于Firefox

时间:2014-04-14 11:40:49

标签: internet-explorer odata internet-explorer-10 datajs

我有一个SAP Gateway系统,我在其中创建了我在jQuery HTML5页面中使用的OData服务。

在执行HTML页面时,我总是使用Firefox来运行它。现在我希望用户测试应用程序,SAP自动使用IE(我安装了IE 10)。

完全相同的请求,通过OData.read函数(datajs库)发送,并没有在IE中给我任何结果,但在Firefox中它确实如此。我达到了成功的回调函数,但也没有结果。 无论如何,这是其中一项服务。我同时打电话的另一项服务确实让我得到了像Firefox那样的结果。奇怪的是,在成功回调函数中,IE中的头(对象)是空的,但在使用IE调试时,我确实有一个响应头。

我测试的方式是使用eclipse和localhost。 Firefox可以工作,IE没有。

我真的不知道如何解决这个问题并感谢任何帮助!

我的要求JS:

var request = {
    headers: {
        'DataServiceVersion': '2.0',
        'X-CSRF-Token': 'Fetch' // needed for update requests
    },
    recognizeDates: true,
    enableJsonpCallback: true,  // didn't have it for Firefox, added for IE but didn't help
    requestUri: requestURL      // URL is definatelly correct and works in the 2nd request
};
OData.read(request, successCallback, displayError);

根据Firefox请求标头:

Accept             application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
Accept-Encoding        gzip, deflate
Accept-Language        en-gb,en;q=0.5
Cookie             SAP_SESSIONID_IED_200=FHWa0fH1IhO_B_UPFMroJmIzPRjDxhHjtXgAUFa_cwE%3d; sap-usercontext=sap-client=200
DataServiceVersion     2.0
Host               localhost:51407
MaxDataServiceVersion  3.0
Referer            http://localhost:51407/Tool/index.html
User-Agent             Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
X-CSRF-Token       Fetch
sap-client             200

根据IE

请求标头
Accept                  application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
DataServiceVersion  2.0
X-CSRF-Token            Fetch
sap-client          200
MaxDataServiceVersion   3.0
Referer                 http://localhost:51407/Tool/index.html
Accept-Language         sv-SE
Accept-Encoding         gzip, deflate
User-Agent          Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Host                    localhost:51407
DNT                 1
Connection          Keep-Alive
Cookie                  sap-usercontext=sap-client=200; SAP_SESSIONID_IED_200=jrJj5t5Qqs7_mTj01OyqJx3cKhbDxxHjtXgAUFa_cwE%3d

IE调试器中的响应头:

Content-Type                 application/json; charset=utf-8
Content-Length               20
Response                 HTTP/1.1 200 OK
Server                       Jetty(8.1.3.v20120522)
server                       SAP NetWeaver Application Server / ABAP 731
sap-metadata-last-modified   Sun, 13 Apr 2014 12:02:23 GMT
dataserviceversion       2.0
x-csrf-token                 Yc7gWOCfweJbnQHVyp-xxx==

但是对象是空的:

JS

executeRead(url, function (resData, response) {
  // trying to get x-csrf-token but the whole response.header is empty
  cCSRF = response.headers['x-csrf-token'];
  ...
}

响应对象

{
 [prototype] : {...},
body : "{"d":{"results":[]}}",
data : {...},
headers : [],
requestUri : "proxy/sap/opu/odata/sap/SERVICE/EntitySet?$filter=Field eq true",
statusCode : 200,
statusText : "OK"
}

0 个答案:

没有答案