How to run a flow service with an XML input

In this tutorial, let's see the additional steps required to support the XML input for the Flow services and generate an XML output using the below examples:

  • Accept XML as input for flow service
  • Send XML as output from flow service

Accept XML as input for Flow service

  1. Create the Flow service.

  2. Click the icon and define the input field node with type as Object.

    When an XML input is provided to any service for execution, IBM® webMethods Integration converts the XML input to XML node and sends the XML node to the service for execution.

  3. Select xmlNodeToDocument service to convert XML node to a document.

  4. Use math service AddInts to perform mathematical operations on string-based numeric values.

  5. Now, the pipeline will have two fields node and document.

  6. Add required fields under the document and map it to the AddInts service.

This groups the elements under the document field.

Sending XML output from Flow service

  1. Add Transform Pipeline to group the variables that you want to send in a response and drop all unwanted variables.

  2. Next, use the documentToXMLString service to convert the response document to XML String.

  3. Select the Flow function and then select the SetHttpResponse service to set the HTTP response to success or failure along with the response XML.

    Map the XML string to response string and set the response code as required.

    1. On the Overview page, select the Enable Flow service to be invoked over HTTP option. Once the Flow service is enabled to be invoked over HTTP, the HTTP request URL appears.

    2. Download a REST client.

    3. Click Create a request.

    Invoking a service appears as shown below: