Scenario: A SOAP XML data returning web service will be called, and each element of the array type within the returned result will be sent to another API in a specific format.

In this case, two API Call connectors should be added as tasks. The first one is necessary for reading, and the second one is required for writing within the loop.


Task-1: Reading data with the API Call connector

  1. Clicking on the API Call option from the dialog where tasks are listed.
  2. Selecting the "Once" option to specify that the task will run only once.
  3. Entering the relevant web service access information for data reading.
  4. Setting the "soapResponse" value for the output key information to be able to use the data returned from the web service in the next task. (You can name this value as you prefer.)

When this task is executed, the SOAP XML data below will be returned in this example, meaning the "soapResponse" value will contain the following data:

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:example="http://www.example.com">
    <soapenv:Header></soapenv:Header>
    <soapenv:Body>
        <example:users>
            <example:user>
                <example:id>1</example:id>
                <example:name>user 1</example:name>
                <example:description>description of user 1</example:description>
            </example:user>
            <example:user>
                <example:id>2</example:id>
                <example:name>user 2</example:name>
                <example:description>description of user 2</example:description>
            </example:user>
            <example:user>
                <example:id>3</example:id>
                <example:name>user 3</example:name>
                <example:description>description of user 3</example:description>
            </example:user>
        </example:users>
    </soapenv:Body>
</soapenv:Envelope>


Task-2: Sending data to the API with the API Call connector.

  1. Clicking on the API Call option from the dialog where tasks are listed.
  2. Selecting the "Loop" option to indicate that the task will iterate over the array data received from the previous task.
  3. Writing the XPath specifying where the value of the entered output key information ("soapResponse") from the previous task should be processed as an array.
  4. When writing XPath, to specify processing the previous data as XML, the "#/" sign is added to the key information ("soapResponse"). Then, the path where the array elements are located is entered as XPath. Since SOAP XML often includes namespaces, writing XPath with these namespaces can be challenging. In this case, it is recommended to use the local-name() method within XPath. For this example, the following should be written where XPath is specified: {{soapResponse#//*[local-name()='Items']/*[local-name()='Item']}}
  5. Entering the relevant API access information where the data will be sent.
  6. Entering the desired template message information to be sent. If the values of the elements in the loop are to be used within the template message, it is ensured that the data within the respective element is added to the template using the "LOOP_VARIABLE" expression. Along with LOOP_VARIABLE, the XPath information pointing to the SOAP XML data within the element designated for the loop should be entered.

In this example, when the expression {{xmlResponse#/root/users/user}} is executed on the "xmlResponse" data returned from the previous task, it returns 3 elements, indicating that this task will run 3 times.

In the first iteration, the XML within the LOOP_VARIABLE value will be as follows:

<example:user>
                <example:id>1</example:id>
                <example:name>user 1</example:name>
                <example:description>description of user 1</example:description>
</example:user>

Let's assume that the desired template to be applied to this XML is as follows:

{
  "test_id":"{{LOOP_VARIABLE#//*[local-name()='id']/text()}}",
  "test_name":"{{LOOP_VARIABLE#//*[local-name()='name']/text()}}",
  "test_description":"{{LOOP_VARIABLE#//*[local-name()='description']/text()}}" 
}


Note that the text() method is used at the end of the XPath alongside LOOP_VARIABLE to obtain the target data here.


In this case, the request body to be sent with the API Call will be as follows:

{
  "test_id": "1",
  "test_name": "user 1",
  "test_description": "Description of user 1"
}