2

我有一个 SAP 网关系统,我在其中创建在 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"
}
4

0 回答 0