Search

 

Module: Editor

Version: 4.3.0.0

User: Developer

Difficulty: Easy

Introduction

In this exercise we will create a webservice

 

Prerequisites

- The Futurama Editor must be installed.
- Completing the tutorial Creating a Webservice Application first, is recommended. 

 

Description

In this exercise you have to create a webservice that can add two numbers.

Assignment

Create a webservice that can add two numbers. In SoapUI, verify that you get the correct result for different input.

Take the following steps to do so:

  1. Open a Notepad and save the data below as an Xml file in the application folder. This file will serve as a test input file to implement the correct behaviour for our webservice. With this input file, the format of the input is also defined.
     
     
                    2 
                    3 
     
  2. Open the Futurama Editor and open a new document. Save the document in the same folder as the Xml file.
  3. Create a WebService object.
    We have to fill in the properties TestValue and XmlOutput.
    First we will create the TestValue input.
  4. Create a Formula Type String 'Path', with the fuction GetPathToDateFiles().
  5. Create another Formula Type String 'ReadFile', with the function 'ReadFile'. In the Filename you choose for the Formula Concatenate and in the Formula Concatenate you fill in the name of the input xml file (as example Input.xml) and you refer to the Formula Path.
  6. In the Webservice, refer to the ReadFile formula for the property TestValue. Validate in the Results Window that the Input of your test file is visible here.
  7. Now we will create the calculation of the result for the webservice.
  8. Create an XmlNode 'Input'. Go the properties and fill in the URI (http://www.futurama.eu/WebserviceAdd) in the NameSpaces property and choose a prefix, for instance 'a'. In the property Source refer to the formula ReadFile and in the property XPath type in your prefix followed by the element data. (So in our example 'a:data'). Verify that the XmlNode displays your test input in the Results Window.
  9. Create two XmlFields (type Long) within the XmlNode that retrieve both values of the test input ('a:Add1' and 'a:Add2').
  10. Create a Formula that adds both numbers in the XmlFields.
  11. Create an XmlBuilder 'Results' and within the XmlBuilder refer to the Add Formula.
  12. In the Webservice object, refer to the XmlBuilder in the XmlOutput property. Now we have created the result that the webservice has to give back.
  13. To define the name of the webservice, create an InterfacesNode and within it a reference to the Webservice object. The name you choose for this reference is the name you have to use when calling the webservice.

  14. Open SoapUi and verify your application.

Tips

  • You should add a namespace to your Results XmlBuilder as well. See the download for our solution.
  • The Document does not have a StartWebpage (nor other pages), as this is no website application.

Solutions

Download

image

You can download our solution for this assignment by clicking the image at the right. (Futurama 4.3.0.0)
Please note that you can very well have a different solution that is just as good as ours.

Variations

  • (Easy:) Adjust the webservice so that it gives the product instead of the sum of the two input variables.
  • (Medium:) Adjust the webservice so that it gives both the product and the sum as output.
  • (Medium:) Adjust the webservice so that it returns the input variables in the output as well.

 Updated: 2014-07-08