GET /entity.svc failed in batch

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:24:27

问题


I defined a service in dataSources

"dataSources": {
    "mainService": {
        "uri": "/backend/service/v1/entity.svc/",
        "type": "OData",
    }
}

"models": {
    "": {
        "dataSource": "mainService",
        "preload": true,
        "settings" : {
            "sizeLimit" : 500,
            "useBatch" : false,
            "refreshAfterChange": false,
            "defaultBindingMode": "TwoWay",
            "defaultCountMode" : "None",
            "defaultUpdateMethod" : "Put"
        }
    }
}

But for some reason I don't know, ui5 project will call GET /backend/service/v1/entity.svc/ when initial load, which returns several <collection>.

But when I set UseBatch to true, the batched GET request will fail, with payload like this:

 --batch_67d5-9dc2-70e0
Content-Type: application/http
Content-Transfer-Encoding: binary

GET  HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en-US
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
sap-cancel-on-close: true


--batch_67d5-9dc2-70e0-

As it seems like a GET nothing request, the batch request will certainly fail. Is there any UI5/oData expert can tell me what's the point of GET /entity.svc, how to fix this batch or how to skip this request ?


回答1:


I found that it is cause by data binding in sap.m.Table

_bindView : function (sObjectPath) {
  var sAssignedPath = sObjectPath + "/assignedThings",

  this._oModel.read(sAssignedPath , {
    success : this._handleGetAssignedSuccess.bind(this, sAssignedPath),
    error : this._handleGetAssignedError.bind(this)
  });

  oTable.setModel(this._oModel);
}

_handleGetAssignedSuccess : function (sAssignedPath, oMsg) {
  var oTable = this.getView().byId("tableView").byId("assignTable"),
  oJSONModel = new JSONModel(oMsg.results);

  oAssignTable.setModel(oJSONModel);
},

//AssignTable.view.xml
<Table
  id="assignTable"
  inset="true"
  items="{
    path: '/'
  }"
>

items="{path: '/'}" is mean to use in JSON Model data binding, but it also triggered an oData GET '/' Request.



来源:https://stackoverflow.com/questions/46482269/get-entity-svc-failed-in-batch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!