MockServer SAPUI5连接

时间:2016-06-15 06:13:34

标签: javascript mocking sapui5

我试图从模拟服务器获取数据,并且我已经像在this tutorial中那样完成了,但我显然无法访问模拟服务器。

在控制台中出现此错误:

  ?

http://localhost:56141/destinations/northwind/V2/Northwind/Northwind.svc/ItemTypes $跳过= 0&安培; $顶部= 100   404(未找到)

  

实体集的模拟数据" ItemTypesSet"由于无法加载   错误的格式!

mockServer.js

sap.ui.define([
    "sap/ui/core/util/MockServer"
], function (MockServer) {
    "use strict";
    return {
        init: function () {
            // create
            var oMockServer = new MockServer({
                rootUri: "/destinations/northwind/V2/Northwind/Northwind.svc/"
            }); 
            var oUriParameters = jQuery.sap.getUriParameters();
            // configure
            MockServer.config({
                autoRespond: true,
                autoRespondAfter: oUriParameters.get("serverDelay") || 1000
            });
            // simulate
            var sPath = jQuery.sap.getModulePath("myApp.localService");
            oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
            // start
            oMockServer.start();
        }
    };
});

metadata.xml也在那里。

<?xml version="1.0" encoding="UTF-8"?><edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" Version="1.0">
    <edmx:DataServices m:DataServiceVersion="2.0">
        <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="model">
            <EntityType Name="Items">
                <Key>
                    <PropertyRef Name="ItemsID"/>
                </Key>
                <Property Name="ItemsID" Nullable="false" Type="Edm.String"/>
                ...
            </EntityType>
            <EntityType Name="ItemTypes">
                <Key>
                    <PropertyRef Name="ItemTypesID"/>
                </Key>
                <Property Name="ItemTypesID" Nullable="false" Type="Edm.String"/>
                <Property Name="Name" Type="Edm.String"/>
                <Property Name="Items" Type="Edm.String"/>
                <NavigationProperty FromRole="From_ItemTypes" Name="ItemsSet" Relationship="model.ItemTypesItems" ToRole="To_Items"/>
            </EntityType>
            <Association Name="ItemTypesItems">
                <End Multiplicity="1" Role="From_ItemTypes" Type="model.ItemTypes"/>
                <End Multiplicity="*" Role="To_Items" Type="model.Items"/>
            </Association>
            <EntityContainer Name="default" m:IsDefaultEntityContainer="true">
                <EntitySet EntityType="model.Items" Name="ItemsSet"/>
                <EntitySet EntityType="model.ItemTypes" Name="ItemTypesSet"/>
                <AssociationSet Association="model.ItemTypesItems" Name="ItemTypesItemsSet">
                    <End EntitySet="ItemTypesSet" Role="From_ItemTypes"/>
                    <End EntitySet="ItemsSet" Role="To_Items"/>
                </AssociationSet>
            </EntityContainer>
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

我的mockServer.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta charset="utf-8">
        <title>Walkthrough - Test page</title>
        <script
            id="sap-ui-bootstrap"
            src="../resources/sap-ui-core.js"
            data-sap-ui-theme="sap_bluecrystal"
            data-sap-ui-libs="sap.m"
            data-sap-ui-bindingSyntax="complex"
            data-sap-ui-compatVersion="edge"
            data-sap-ui-preload="async"
            data-sap-ui-resourceroots='{
                "myApp": "../"
            }'>
        </script>
        <script>
            sap.ui.getCore().attachInit(function () {
                sap.ui.require([
                    "hdc/localService/mockserver",
                    "sap/m/Shell",
                    "sap/ui/core/ComponentContainer"
                ], function (mockserver, Shell, ComponentContainer) {
                    mockserver.init();

                    new Shell({
                        app : new ComponentContainer({
                            height: "100%",
                            name: "myApp"
                        })
                    }).placeAt("content");
                });

            });
        </script>
    </head>
    <body class="sapUiBody" id="content">
    </body>
</html>

0 个答案:

没有答案