Altova MapForce 2025 Enterprise Edition

Context and Efficient Usage of Resources

Home Prev Top Next

This topic explains what determines how many times a Web service is called. In a mapping that contains a Web service call, if the context allows it, the same Web service may be called multiple times, which you will normally want to avoid. Consider the cases outlined below.

 

Request

If the connection to the Request item of the Web service component contains a sequence of values, the Web service will be called multiple times, once for each item in the sequence.

 

Response

Depending on the connections in the Response part, a Web service might be called multiple times, which may not be the desired configuration. Consider the examples below.

 

Example 1

For example, the Web service illustrated below is called twice, because there is no common parent context for the statusCode and body nodes in the target component.

mf_semantics_09

According to the general mapping rule, processing begins with the target root item (Rows in this case). The Rows node does not have a connection, so MapForce proceeds down the hierarchy. To populate the statusCode target item, the first call to the Web service is made. Next, the mapping must populate the body item. Therefore, it makes the second call to the Web service. If there were more children of the Rows node connected to the Web service, a new call would be made for each child node.

 

Since neither statusCode nor body has an explicit parent context (in other words, their parent is not connected to a source item), they cannot reuse any data from their parent and must retrieve it individually from the Web service call component. You can easily solve this problem by drawing a connection from Response to Rows, as shown below:

mf_semantics_10

Thanks to the connection between Response and Rows, the common parent context now exists for all the child nodes of the Rows node, and the Web service is now called only once. After the first call, all the Web service data is in the current context and is available to the children of the Rows element. Therefore, no redundant Web service calls will take place.

 

Example 2

In the second example, the response of the Web service call is mapped to two target components (screenshot below). In MapForce, you can preview only one output at a time, and each time you click the ic-preview button of any of the targets, a call is made to the Web service. However, if you execute the mapping with MapForce Server or as a FlowForce job, the mapping will produce all the outputs in the order specified, from top to bottom. This also means that the mapping will make two Web service calls, for each target separately, because there is no common target context.

MF_API2MultTargets

A better solution would be to output the response to a single target component. You can then split it into multiple components, if necessary. See the mapping design below.

mf_ws_02

 

Web services in user-defined functions

If a Web service is inside a user-defined function, and if the UDF gets called multiple times for the duration of the mapping execution, then the Web service will be called at least as many times. This can be avoided by configuring the UDF settings. For details, see Context in UDFs.

 

© 2018-2024 Altova GmbH