1

I'm building a Logic App to pull data from my on-premise SQL database -> transform it into XML -> Send it through to SOAP API.

Here's the example data what I'm getting into Logic App from my on-premise database:

{
    "ResultSets": {
        "Table1": [
            {
                "ID": "VM001",
                "FirstName": "TestFirstName",
                "LastName": "TestLastName",
                "Email": "test1@company.com",
                "DOB": "1990-05-05"
            },
            {
                "ID": "VM002",
                "FirstName": "TestFirstName2",
                "LastName": "TestLastName2",
                "Email": "test2@company.com",
                "DOB": "1990-06-06"
            }
        ]
    },
    "OutputParameters": {}
}

...then my plan is to call an internal API and apply some sort of policy (I believe we can use Liquid Template in Inbound/Outbound Policies without using Integration Account or Azure Function) to transform above data into below XML but I'm struggling with it:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <userRequest>
         <extMessageId>12345</extMessageId>
         <users>
            <!--1 or more repetitions:-->
            <user>
               <ID> ID from JSON data </ID>
               <!--Optional:-->
               <FirstName> FirstName from JSON data </FirstName>
               <LastName> Lastname from JSON data </LastName>
               <Email> Email from JSON data </Email>
               <DOB> DOB from JSON data </DOB>
            </user>
         </users>
      </userRequest>
   </soapenv:Body>
</soapenv:Envelope>

Can someone please help.

Victor McIntyre
  • 93
  • 1
  • 10

1 Answers1

5

For this requirement, I create a APIM and edit its policy as below for your reference:

enter image description here

As you mentioned the fields <FirstName>, <LastName>... are optional. If you still want the <FirstName> tag show with null value, you don't need to do anything else. If you don't want show the <FirstName> tag when it has no value, you need to edit the liquid template as below:

enter image description here

Hope it helps~

Hury Shen
  • 14,948
  • 1
  • 9
  • 18