Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Process XML in Azure Logic App

I'll start with the behavior we are looking to have:

  1. Take in a file (be it JSON or XML, but right now we would prefer XML although we have control over this),
  2. Parse it to find the "type" of the file
  3. Transform the file to match one of a few different XML formats
  4. Send it off to a pre-determined endpoint and back to the caller

Our initial research made it look like BizTalk with an Azure logic app would be a good fit for this, but now that I'm working on a Proof of Concept I am running into roadblocks, namely:

  • BizTalk is seemingly not supported in the latest version of Azure (2015-08-01-preview)
    • I read this in the comments section of one of the articles I read, but cannot find the reference now, is this true?
  • Parsing XML is not supported (I read in one of the 100 articles I've read on this that non-JSON requests are treated as binaries that cannot be parsed in a logic app), which would mean we have to transform our existing XML into JSON to call into Azure, only to transform it back into XML

I've been able to create a logic app, expose an endpoint, call it with a JSON body, and have the logic app parse that JSON and conditionally perform actions, and once I figured out how to do all of that, it was pretty impressive.

So my question is two-fold:

  1. Is our situation a good candidate for an Azure Logic App (or perhaps a different type of Azure app)?
  2. If so, is BizTalk the proper way to transform our files into the needed output XML formats?
    1. From what I'm seeing online, there isn't a way to create BizTalk transform files in VS 2015?

      BizTalk server projects are not compatible with Visual Studio 2015 or Visual Studio 2013.

like image 632
Sven Grosen Avatar asked Mar 22 '16 12:03

Sven Grosen


2 Answers

We recently shipped Preview of [Enterprise Integration Pack] (EIP) for Logic Apps. As part of this release, a bunch of xml processing capabilities have been added to Logic Apps.

  1. [JSON to XML] and vice versa: You can use the json() and xml() functions that are natively available in Logic Apps definition.
  2. XML Transform: You can now use the new XML Transform action which is based upon XSLT 1.0.

Beyond these, Logic Apps also has HTTP requests/response capabilities which can be used to call HTTP endpoints.

Hope this helps.

Thanks, Vinay

like image 147
Vinay Singh Avatar answered Oct 15 '22 19:10

Vinay Singh


  1. Receive XML POST request.
  2. Transform the XML. - Use content as triggerBody() and map using XSLT. You can set the XML format here.

    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0">
    <xsl:template match="/">
    <Header>
    <Something>
    <xsl:value-of select="soap-env:Envelope/soap-env:Body/a:Something/@value"/>
    </Something>
    </Header>
    </xsl:template>
    </xsl:stylesheet>
    
  3. Transform XML to JSON - Use content body('transform_XML') and map using XML to Json.

    {"Something": "{{content.Something.Value}}"
    
  4. Parse JSON - Use content body('transform_XML_to_JSON')
  5. HTTP Response - set the values you want returned as body('Parse_JSON')['Value'] into the Body.

    <Header>
    <Something>
    <value = "body('Parse_JSON')['Value']"/>
    </Something>
    </Header>
    
  6. You can also create a blob with this and send to a data factory.

like image 23
Watsyyy Avatar answered Oct 15 '22 20:10

Watsyyy