XML Validation – Logic Apps

Posted: July 11, 2022  |  Categories: Azure BizTalk

XML Validation is one of the cornerstones of BizTalk Solutions .This blog shows how to do the same in Azure Logic Apps.

XML validation the BizTalk way

To begin with we are going to lean on Saravana’s blog above to set the scene for Logic Apps. Firstly, let’s use a direct quote. “

BizTalk allows you to verify the validity of the incoming Xml message against deployed schema in few different ways. Some of the easy options are 1. Using XmlReceive pipeline and setting the ValidateDocument property to true. 2. Create a custom Receive Pipeline and use the XmlValidate pipeline component in the validate stage. In both the scenarios, the incoming message is validated inside a receive pipeline and an exception is raised if the message fails validation, eventually suspending the pipeline service instance.


Furthermore he states

The Xml validation component supplied with BizTalk (both the above cases) only notifies you about the very first error message it encounters.


Thus I want to discover whether the Logic App XML Validation task suffers the same limitations.

The schema

To start with I am going to use an Invoice schema that;

  • Only allows ten digit Purchase Order Number.
  • Requires that each Item Line number is unique.

Firstly restrict the PO number to have minimum and maximum facet value.

Secondly constrain the BuyerPOLineNumber to be unique. This is a very useful but little know way to ensure unique XML records. There are very few examples of using this in the BizTalk world. The best example is by Johann Cooper.

The test xml contains an invalid BuyerPOLineNumber and a repeating line number.

Validating this instance file against the schema in Visual studio, returns an error because it contains a duplicate BuyerPOLine of 10 in two of the InvoiceLine records. The error details the name of the unique constraint as well as which duplicate value broke the constraint. Providing unique values for the BuyerPOLine and a ten digit PO number elements results in the instance file validating successfully.

The Logic App

Firstly the a trigger gets the invoice from a service bus. Secondly XML validation task validates the invoice against the invoice message. Thirdly a condition shapes tests for error using this expression.


Finally transform and send the invoice if true. Alternatively, log the validation error to a SQL database.

The result of XML validation

Indeed the result of the output in the validation shape shows all validation errors. This is much better than the BizTalk XMLDissembler pipeline component which only notifies you about the very first validation error it encounters.

    "errors": [
            "message": "The 'BuyerOrderRef' attribute is invalid - The value 'A300557675' is invalid according to its datatype 'Float' - The string 'A300557675' is not a valid Single value.",
            "lineNumber": 1,
            "linePosition": 326,
            "severity": "Error"
            "message": "There is a duplicate key sequence '10' for the 'http://BidOne.Common.Schemas.Internal.Invoice.IF_INVOICE_v2:buyerpolinenumber' key or unique identity constraint.",
            "lineNumber": 1,
            "linePosition": 2582,
            "severity": "Error"


As a final point, we have shown that the XML validator Logic App action yields all validation failures. Conversely, in the case of BizTalk one must use a special XML Validator pipeline.


Back to Top