Skip to Content

Hello community,

I presented here the possibility how to use an alternative minimalistic server environment for UI5. But with this kind of server it is not possible to use Web or OData services. Sure, you can use the MockServer functionality from the UI5 framework, but in this case you don’t have any chance to interfere between the response and the request from the UI5 framework. Often it is not necessary, but for this case of requirement I build MockAServ.

MockAServ is a web server simulator. With MockAServ you can define up to ten different responses. It catches the URI of the request and sends the text from the editor of MockAServ as response back, if the URI is defined in MockAServ. You can easily define and edit your responses on the fly. On this way you have the chance to check the behaviour of the requested application for different kind of responses. With MockAServ you can easily mock OData or Web service responses.

MockAServ is cross origin scripting (CORS) ready. You can executes it on the same domain as your local web server with another port. Your request must now include the the port. MockAServ offers a request protocoll, on this way you know exactly which requests your application sends to the server. With MockAServ is it possible to simulate a special part of back end structures easily, it is easy to handle and portable. You can find MockAServ here, it is free.

/wp-content/uploads/2016/02/001_891623.jpg

Here an example how to use MockAServ with HFS and OpenUI5:

<!doctype html>


<html>


  <!– Example from http://services.odata.org/V4/OData/OData.svc/ –>


  <head>


    <title>OData test</title>

    <meta http-equiv=”Content-Type” content=”text/html” />

    <meta charset=”ISO-8859-1″ />

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge” />


    <script type=”text/javascript” src=”resources/sap-ui-core.js”

      id=”sap-ui-bootstrap”

      data-sap-ui-libs=”sap.ui.commons, sap.ui.table”

      data-sap-ui-theme=”sap_bluecrystal”>

    </script>

    <script type=”text/javascript”>

//-Begin—————————————————————-

  //-function main——————————————————

    function main() {

      //-Variables——————————————————

        var oModel, oTable;

      oTable = new sap.ui.table.Table(“tableId”,{

        visibleRowCount : 8,

        editable : false,

        width : “500px”

      });

      oTable.addColumn(new sap.ui.table.Column({

        label : new sap.ui.commons.Label({text: “ID”}),

        visible : true,

        template : new sap.ui.commons.TextView({text: “{ID}”})

      }));

      oTable.addColumn(new sap.ui.table.Column({

        label : new sap.ui.commons.Label({text: “Rating”}),

        visible : true,

        template : new sap.ui.commons.TextView({text: “{Rating}”})

      }));

      oTable.addColumn(new sap.ui.table.Column({

        label : new sap.ui.commons.Label({text:”Price”}),

        visible : true,

        template : new sap.ui.commons.TextView({text: “{Price}”})

      }));

      oModel = new sap.ui.model.odata.ODataModel(“http://127.0.0.1:9981/OData.svc“);

      oTable.setModel(oModel);   

      oTable.bindRows(“/Products”);

      oTable.placeAt(“content”);

    }

//-End——————————————————————

    </script>

  </head>

  <body class=”sapUiBody” role=”application” onLoad=”main()”>

    <div id=”content” />

  </body>

</html>

Note the different port addresses between the local web server (8888) and MockAServ (9981).

/wp-content/uploads/2016/02/001_891623.jpg

It is often very interesting to see which requests are sent to the server and also how the application reacts for different kind of responses – not only for error analysis.

Enjoy it.

Cheers

Stefan

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply