Altova MapForce 2024 Enterprise Edition

Example: Calling a REST-Style Web Service

Home Prev Top Next

This example shows you how to call a generic HTTP Web service from MapForce. The description of the Web service called in this example can be found at This Web service returns information about airport statuses (e.g., airport closures, delays, etc.) in different US airports. The example is accompanied by a mapping design that is available at the following path: MapForceExamples\AirportStatus.mfd.


In this example, there is no request structure, and the response structure of the Web service is a DTD schema that is available at the following path: MapForceExamples\AirportStatus.dtd. The response will be mapped to an XML component that is based on AirportStatus.dtd.


To configure the REST Web Service call, take the steps described below.


Step 1: Add Web Service Call

In this step, the task is to add a Web Service Call component to the mapping and define the Call's parameters. Take the steps below:


1.Make sure the transformation language of the mapping is Built-In.

2.In the Insert menu, click Web Service Function. This opens the Web Service Call Settings dialog (screenshot below).

3.Under Service Definition, click Manual.

4.Set the request method to GET and the URL to


5.In the Structures section of the Web Service Call Settings dialog, click the Edit button next to the Response field. This opens the Response Structure dialog (see below), in which you need to supply the schema of the Web service response. The schema can be found at the following path: MapForceExamples\AirportStatus.dtd.


6.Click OK. The Web service is now available in the mapping area (see below).



Step 2: Add XML output

In the second step, the goal is to add a target component and create connections between the Web Service Call and the target. Follow the instructions below:


1.In the Insert menu, click XML Schema/File.

2.Click Choose a file and browse for the MapForceExamples\AirportStatus.dtd and click Open.

3.When prompted to supply a sample XML file, click Skip (there is no need for a sample XML file since it will be generated).

4.Connect the AIRPORT_STATUS_INFORMATION node of the response body of the Web service to the AIRPORT_STATUS_INFORMATION node of the XML component, as shown below.



Step 3: Execute the mapping

The last step is to call the Web service: Click the Output button to execute the mapping and preview the generated output. If the Web service call is executed successfully, the Output pane will display the returned XML structure. If the call is not successful, MapForce will return an error. For example, you may get an HTTP code 404 message if the requested information has not been found.


In our example, we have received the following information about airport statuses:



 <Update_Time>Fri Sep 15 12:04:41 2023 GMT</Update_Time>



         <Name>Airport Closures</Name>




                         <Reason>!BOS 09/153 BOS AD AP CLSD TO NON SKED TRANSIENT GA ACFT EXC PPR 617-561-2500 2309081532-2310010359</Reason>

                         <Start>Sep 08 at 15:32 UTC.</Start>

                         <Reopen>Oct 01 at 03:59 UTC.</Reopen>




                         <Reason>!LAS 07/017 LAS AD AP CLSD TO NON SKED TRANSIENT GA ACFT EXC PPR 702-261-7775 2307072300-2310052300</Reason>

                         <Start>Jul 07 at 23:00 UTC.</Start>

                         <Reopen>Oct 05 at 23:00 UTC.</Reopen>




                         <Reason>!MIA 09/078 BCT AD AP CLSD EXC HEL OPS FM ALL APN MON-FRI 0100-1100 2309110100-2309291100</Reason>

                         <Start>Sep 11 at 01:00 UTC.</Start>

                         <Reopen>Sep 29 at 11:00 UTC.</Reopen>






If you have MapForce Server, you can also compile the mapping to a mapping execution file (*.mfx) and execute it from the command-line or from the MapForce Server API on the server machine where MapForce Server runs (see Compiling Mappings to MapForce Server Execution Files ).


You have now finished creating a generic HTTP Web service call that uses a GET method to retrieve airport status data in real time. For more information about working with generic Web services, see also Adding a Web Service Call (REST-Style).


© 2018-2024 Altova GmbH