从 Eclipse 使用 OData

Consuming OData from Eclipse

我一直在使用文档练习 SAPUI5,但他们使用 SAP Web IDE 来使用 OData 服务。但是,因为我的公司不会将他们的服务器暴露在云端,所以我不能使用 SAP Web IDE 所以我需要使用 eclipse。我需要一步一步的教程(对于傻瓜)来使用 Eclipse 中的 SAPUI5 使用 OData。我已经知道如何创建它们,但不知道如何从 eclipse 中使用它们。

我使用 Northwind 的 OData 服务,但使用 SAP,我需要凭据和其他东西。

"dataSources": {
  "invoiceRemote": {
    "uri": "https://services.odata.org/V2/Northwind/Northwind.svc/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0"
    }
  }
}

我会给你一些提示,但不是完整的教程。

在 Eclipse 中工作与在 WEB 中工作没有什么不同 IDE。 首先你需要使用 JSONModel()。您可以找到参考 here.

创建一个 JSONModel 对象,然后使用方法 loadData。 对于 sURL 使用(在您的示例中): "https://services.odata.org/V2/Northwind/Northwind.svc/?$format=json"

然后,您的前端就会有您的 oData。现在你只需要学习如何在你的视图元素中使用它。你可以学习它here

如果您需要进一步的解释,请提出小而具体的问题,以便更容易回答您的需求。

[...] because they won't expose their server to the cloud, I can't use SAP Web IDE

基于云的 Web IDE 的替代方法是 Web IDE Personal Edition which you can deploy on your local machine but still runs in the browser (localhost). Create a corresponding destination file 连接到远程系统,其余部分与旧 Orion-based Web IDE 在云端。

这是来自 odata.org(例如 Northwind)

的服务的目标文件
Description=OData service from odata.org for testing, tutorials, demos, etc.
Type=HTTP
Authentication=NoAuthentication
WebIDEUsage=odata_gen
Name=odata_org
WebIDEEnabled=true
URL=http\://services.odata.org/
ProxyType=Internet
WebIDESystem=odata_org

否则,如果您想坚持使用 eclipse,请查看文档主题

使用 northwind 的 OData 的示例:(这是我在 eclipse 中实现的,但与 sap web 的唯一区别 ide 个人版(我还没有尝试过,但它应该可以工作)你必须配置服务的目标文件)

manifest.json

 //between sap.app key you put this:
            "dataSources": {
            "mainService": {
                "uri": "/northwind/V2/OData/OData.svc/",
                "type": "OData",
                "settings": {
                    "odataVersion": "2.0",
                    "localUri": "localService/metadata.xml"
                }
            }
        }

...
// this can be empty the if your using more than two just one can be empty
"": {
            "dataSource": "mainService",
            "preload": true
        }

我认为我将使用数据:

<List
                id="list"
                items="{
                    path: '/Categories',
                    sorter: {
                        path: 'Name',
                        descending: false
                        },
                    groupHeaderFactory: '.createGroupHeader'
                }"
                busyIndicatorDelay="{masterView>/delay}"
                noDataText="{masterView>/noDataText}"
                mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
                growing="true"
                growingScrollToLoad="true"
                updateFinished="onUpdateFinished"
                selectionChange="onSelectionChange">
                <infoToolbar>
                    <Toolbar
                        active="true"
                        id="filterBar"
                        visible="{masterView>/isFilterBarVisible}"
                        press="onOpenViewSettings">
                        <Title
                            id="filterBarLabel"
                            text="{masterView>/filterBarLabel}" />
                    </Toolbar>
                </infoToolbar>
                <items>
                    <ObjectListItem
                        type="Active"
                        press="onSelectionChange"
                        title="{Name}">
                    </ObjectListItem>
                </items>
            </List>

如果您要使用和为您制作的 odata 或消费只需将 url 粘贴到您的密钥数据源的属性 "uri" 中(类似这样的内容:“https://proxy/name:port/sap/opu/odata/SAP/ZNAME_OF_YOUR_CREATED_ODATA_SRV “别担心这个 url 是你可以看到它的时候哟 /IWFND/MAINT_SERVICE )和什么时候已经部署它只是留下这样的 uri /sap/opu/odata/SAP/ZNAME_OF_YOUR_CREATED_ODATA_SRV