Search

 

Module: Editor

Version: 4.3.0.0

User: Developer

Difficulty: Medium

Introduction

In this exercise we will create a webservice

 

Prerequisites

- The Futurama Editor must be installed.
- Futurama Runtime must be installed.
- Completing the tutorial Reading and processing XML-data in Futurama  first, is recommended. 

 

 

Description 

In this exercise you have to create a webservice that looks up the entry in a DataTable, and returns the information desired from it.

Assignment

In this exercise we want to create a webservice that gives us the nationality of the chosen person (name).

Use the Table below here:

Index   Spouse  Gender  Nationality  City 
Frank Yes Man Dutch Rotterdam
Sarah  No Woman French Lyon
John No Man English Manchester
David Yes Man American Washington DC

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.
     
    
    Sarah
    
  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/WebserviceNationality) 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 an XmlField (type String) within the XmlNode that retrieves the value of the test input ('a:Name').
  10. Create a DataTable that holds the data of the table mentioned above in the assignment.
  11. Create the formula VLookUp and refer in the Lookup_Value to the XmlField (Name), refer in the table to the DataTable and fill in the column number corresponding with the Nationality.
  12. Create an XmlBuilder 'Xml_Output' and within the XmlBuilder refer to this lookup Formula.
  13. 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.
  14. 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.

  15. 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:) Change the output from Nationality into Spouse
  • (Easy:) Extend the webservice by returning all information about the person you have.
  • (Difficult:) Turn your webservice around: Let the nationality be the input, and give back the person as a result. (You might have to change your input file)

Updated: 2014-07-09