SAPUI5 模拟服务器不接收请求

SAPUI5 mock server doesn't receive requests

我没有找到解决这个问题的办法。我目前正在使用 CRUD Master-Detail Application WebIDE 模板并使用 OData[=30= 添加了一些自定义函数] 来电。当 运行 带有模拟服务器的应用程序加载模拟数据时。到目前为止,一切都很好。但是,如果我向模拟服务器发送读取请求,它 throws a 404 not found error.

请求URL

https://webidetesting[...].dispatcher.hana.ondemand.com/here/goes/your/serviceurl/MyEntity(12345)

这是我的 index 文件中的模拟服务器部分 flpSandboxMockServer.html:

<script>
        sap.ui.getCore().attachInit(function() {

            sap.ui.require([
                "my/project/localService/mockserver"
            ], function (mockserver) {
                // set up test service for local testing
                mockserver.init();

                // initialize the ushell sandbox component
                sap.ushell.Container.createRenderer().placeAt("content");
            });
        });
    </script>

OData 读取调用如下所示:

onRemoveMyEntityBtnPress: function () {
        let oEntityTable = this.byId("lineItemsList");
        let aSelectedItems = oEntityTable.getSelectedItems();
        let oModel = this.getModel();

        for (let oSelectedItem of aSelectedItems) {
            let sBindingPath = oSelectedItem.getBindingContext().getPath();
            let sGuid = this._selectGuidFromPath(sBindingPath);

            this._loadEntityFromService(sGuid, oModel).then((oData) => {
                // Next step: change a property value
            }).catch((oError) => {
                jQuery.sap.log.error(oError);
            });
        }

        if (oModel.hasPendingChanges()) {
            oModel.submitChanges();
        }
    },
_loadEntityFromService: function (sGuid, oModel) {
        return new Promise((resolve, reject) => {
            oModel.read(`/MyEntity(${sGuid})`, { 
                success: (oData) => {
                    resolve(oData);
                },
                error: (oError) => { // call always ends up here with 404 error
                    reject(oError);
                }
            });
        });
    },

有人知道我还需要做什么才能将我的阅读请求发送到模拟服务吗?

终于找到解决办法了! 我使用 OData 实体类型来读取我的实体。我将目标更改为我的实体集,现在它不会引发 404 错误。