Search

 

Edition: Futurama Webservice

Module: Futurama WebAPI

User: User name

Prerequisites

- opsomming eisen/not applicable

Introduction

Explains the Safe2Save webapi sample

 

Description

To illustrate the flexibility of Futurama WebAPI, we have constructed a sample application called “Safe2Save”. It is a Futurama application that allows a user to calculate interest over a number of years, and view a chart or table containing the compound savings over sequential years.
This sample Futurama application is stored in a single location on our servers, and accessible through two public addressable URL’s:

For Futurama Web, a webbrowser can be navigated to the address http://test.actuit.nl/safe2save/web

For Futurama Webservice/WebAPI, a webservice capable application can be navigated to the address http://test.actuit.nl/safe2save/webapi

To test this, we have created a SOAP-UI project that contains various calls and scenarios that can be used to mimic the user interaction achievable through the normal Website variant. To obtain this sample project, please contact us at info@actuit.nl

The SOAP-UI project

The SOAP UI project consists of 3 sections:

  • A REST section, containing sample requests accessing the REST web service.
  • A SOAP section containing the same samples, but for SOAP calls.
  • A Scenario section consisting of three test cases that consist of identical steps, but for different web service protocols: SOAP and REST. A third scenario is set up to be similar to the REST scenario, but using IDPrefixes.

Should any details entailing the WebAPI requests or responses be desired, please refer to the documentation.

The REST sample requests (WebAPI REST)

The provided sample request contain a simple call to the /rest/webapi relative path. It sends two values to the server by performing a HTTP Post method containing a JSON string with two properties: The folder value “Savingsaccount” (which contains the sample application), and the document name that contains the application: “website.xml”. When this request is made, a response will be returned in the same language (JSON) containing the WebAPI properties required for recreating all aspects of the Futurama Website variant performing the same action (opening the website).

  • It contains a string of HTML rendering the internal Futurama Webcontrol structure in the PanelsJSON property.
  • It contains a list of scriptfiles and javascript files required to process any interaction with the HTML code.
  • It contains a Request validation token that must be passed to the next request.
  • It contains a SessionID that creates session continuity.
  • The meaning for each property can be viewed in the WebAPI documentation.

Another sample call is the call to the GetResource method. This allows retrieval of files from the server in base64 encoded binary format. For details, please refer to the documentation.

SOAP Sample requests (WebAPI SOAP)

This section contains two similar requests as the previously mentioned REST variant. However these calls are made through the SOAP protocol, using XML as the data structure instead of JSON.

Scenarios

The Scenario section contains two sections, one for REST and one for SOAP webservices. The individual steps are identical, only the protocol differs.
The following steps are provided:

  1. Open Site: This is the first request, opening the starting page.
  2. Select 3 percent: In this step the value “3%” is selected in the dropdown list, followed by clicking the “Calculate” button.
    When this step is performed within the Futurama Web application, it will be achieved through an AJAX (partial) postback.
  3. Download PDF: The “download” button is clicked, and a PDF file is generated, containing the chart. This file will be offered as a download to the client.
  4. Navigate to overview: The “next” button is clicked, and the client receives the output for a new page containing a table of calculated values.

Running the scenario within a browser

The four steps mentioned above can be manually tested within Futurama Web by navigating a web browser to the URL http://test.actuit.nl/safe2save/web and performing the actions mentioned above.

Running the scenario using SOAP-UI in WebAPI

The SOAP scenario contains the four steps mentioned above as consecutive requests to the WebAPI SOAP endpoint at the URL http://test.actuit.nl/safe2save/webapi. We will walk through all of these to provide some insight:

Open site

We provide a simple request by supplying the folder and document to be loaded. The response contains many properties that are needed to build a complete HTML page, such as CSS- and Javascript file references. The main content however is contained within the Panels property, because it contains a string of HTML code that is rendered within WebAPI.

Select 3 percent

In the request, we provide a new value for the dropdownlist with ID=14. We also trigger the event caused by pressing the button with ID=21. These two actions are provided in the Parameters collection.
The request in this step is actually a “partial” request, because it only retrieves the WebPanel with ID=6. This has to be forced by setting the “ProcessFullPage” property to the value “false”.

Download PDF

This is a regular request, that triggers the event behind the button with ID=1208. That causes a document to be generated within Futurama, and this file is returned in the form of a Base64 encoded string within the responses “Download” element. It also contains the documents Mimetype. No HTML is returned, as this is also the case in the Web variant of the step (the browser only sees a download, but the page remains).

NavigateToOverview

This final step consists of triggering the event behind button with ID=78 that causes a Navigator to change the page. The response shows the HTML code for a table containing calculated values.

REST Scenario (JSON)

The REST Scenario contains the exact same teststeps as the SOAP Scenario mentioned above, but written in JSON for the REST webservice. The Response and Request objects should contain the same values.

REST Scenario with IDPrefixes

An IDPrefix can be provided in WebAPI requests. This prefix is optional, but allows the Futurama WebAPI rendering engine to transform the regular control id’s to an expanded version, so that they would not collide with the HTML id properties of the website that you would like to paste the Futurama HTML code into.
For this reason, a separate cloned Rest scenario is provided, using these prefixes (in this case the prefix ‘MyPrefix’) so that this mechanism can be tried.

Transferring response values to requests (SOAP-UI)

In order to guarantee continuation of the internal session within the Futurama WebAPI application, the webservice requests need to supply a SessionID and a Request validation token. These values are returned in every response. Subsequent requests need to re-use the values within the request. SOAP-UI has a mechanism to transfer these values, called property-expansion. This mechanism is used in the scenarios by supplying a string of code to the request, so that Soap-UI knows where to retrieve this value from. An example for re-using the sessionid from a previous response in a new (JSON) request:

"SessionID":"${DownloadPDF#Response#$.SessionID}"

This example shows that the SessionID property will be filled with the SessionID found in the response of the “DownloadPDF” step.

Related Topics

  • WebAPI: The main documentation for Futurama WebAPI.
  • GetResource: The documentation for retrieveing files within the WebAPI application.

External Links

  • Soap UI: A handy program to access webservices.

Feedback

If you have any questions about this subject or if you want to provide us feedback please send us an e-mail.

Updated: 2017-05-15