Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

SAP Cloud Integration offers capabilities to validate the XML payload against a given XML Schema. XML Validator (version 1.x) can validate XML against the XSD schema 1.0.

With September 2018 release, this validation capability has been enhanced to provide the support for XSD  schema 1.1 as well. This release is planned to reach customers after September 30.

In this blog, I would describe distinctive features of XMLValidator that helps you to validate XML payloads.

Scenario 1: Validate XML against XML Schema– Stop Message Processing on Validation Failure  

Consider a scenario where you want to stop processing the message as soon as the validation error occurs. For demonstrating the scenario, I created a simple integration flow as shown below:


  XMLValidator: Browse the XSD and keep the Prevent Exception on Failure checkbox unchecked.


Exception Content Modifier: Enter the header in the Message Body of the Content Modifier as shown below.


Run the scenario with a Validation error: 

You would see the exception from the Exception sub process as shown below:

Tracing of the message flow looks as shown below:

Scenario 2: Validate XML against XML Schema – Continue Message Processing During Validation Failure

Consider a scenario where you want to continue processing the message even after the validation error occurs on XML Validator.

For demonstrating the scenario, I extended the above integration flow as shown below.


XML Validator : Select Prevent Exception on Failure checkbox


Create a router with a condition ${header.SAP_XmlValidationResult} != 'null' to handle the scenarios in case of validation failures .

Once Prevent Exception on Failure option is checked,  the processing will continue processing without throwing an exception. You can handle the validation error scenarios with a route condition as shown below:

After Validation Error Content Modifier: In the Validation_Error route content modifier add Validation Error Result: ${header.SAP_XmlValidationResult} in the Message Body to capture the validation result.


Run the scenario with a Validation error: 

You would get the output from Validation_Error route as shown below:


Tracing of the Message flow looks as shown below:

NOTE: All the headers are case-sensitive. Use SAP_XmlValidationResult with the same case-sensitivity.

NOTE: The Validation Result is also available as an attachment in the Message Processing Log.


Scenario 3: Validate XML against XML Schema 1.1

XML schema 1.1 comes with a lot of features like Assertions. SAP Cloud Integration started supporting XSD 1.1 with XMLValidator (version >= 2.x). For more details on XML Schema 1.1 features, you may refer the documentation .

In the above example scenario, consider that I would like to introduce another conditional validation on minprice and maxprice. The condition that I want to apply is minprice should be less than maxprice.

 In the xsd, I just need to introduce a condition <xsd:assert test="minprice le maxprice" /> 

 On running the scenario, you would get the additional assertion validation errors as shown below:

You may also refer the documentation from Saxon to understand the line-number and column-number

NOTE: From XMLValidator version 2.0 onwards, only SAP_XmlValidationResult header is retained. All the old headers like XmlValidationResult are deprecated.



      We learnt about different capabilities of XMLValidator with examples from different scenarios. See you again with another blog on exciting new features from Cloud Integration!