In this exercise we will create a webservice
- The Futurama Editor must be installed.
- Futurama Runtime must be installed.
- Completing the tutorial Reading and processing XML-data in Futurama first, is recommended.
In this exercise you have to create a webservice that looks up the entry in a DataTable, and returns the information desired from it.
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 |
Take the following steps to do so:
- 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.
- Open the Futurama Editor and open a new document. Save the document in the same folder as the Xml file.
- Create a WebService object.
We have to fill in the properties TestValue and XmlOutput.
First we will create the TestValue input.
- Create a Formula Type String 'Path', with the fuction GetPathToDateFiles().
- 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.
- 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.
- Now we will create the calculation of the result for the webservice.
- 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.
- Create an XmlField (type String) within the XmlNode that retrieves the value of the test input ('a:Name').
- Create a DataTable that holds the data of the table mentioned above in the assignment.
- 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.
- Create an XmlBuilder 'Xml_Output' and within the XmlBuilder refer to this lookup Formula.
- 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.
- 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.
- Open SoapUi and verify your application.
- 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.
You can download our solution for this assignment by clicking the image at the right. (Futurama 126.96.36.199)
Please note that you can very well have a different solution that is just as good as ours.
- (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)