SlideShare a Scribd company logo
Ankit Lawaniya
9/3/2017 Ankit Lawaniya 1
The Schema Validation filter takes XML inputs and validates these against a
referenced XSD schema. Typically, we’ll place it at the start of the Mule flow
to determine whether the incoming message or event should be handled or
not, allowing the message to only continue on along the flow when the filter
validations are met and the included XML is considered valid. Schema
Validator is provided out of the box with Mule.
9/3/2017 Ankit Lawaniya 2
A common use case in Mule ESB flows is validating if an XML document is
valid against a corresponding XSD, so we can make sure we are receiving the
correct XML, and will forward it for the further processing.
Syntax:
<mulexml:schema-validation-filter
schemaLocations="src/main/resources/File/Process/Schema.xsd"
returnResult="true" name="OrderData_Schema_Validation"
doc:name="Schema Validation" />
9/3/2017 Ankit Lawaniya 3
The "standard" way of Validating XML schema in Mule is by using the
schema-validation-filter and especially in combination with the message-
filter.
In a case when you want to get an exception and/or call another flow when
the validation fails, you could wrap the schema validation filter inside a
message filter and then use "onUnaccepted" and "throwOnUnaccepted"
configuration attributes to determine the behavior.
Here we have wrapped the schema-validation-filter in a message-filter and
set throwOnUnaccepted to "true.“
<message-filter throwOnUnaccepted="true" >
<mulexml:schema-validation-filter
schemaLocations="/File/Process/Schema.xsd" returnResult="true"
name="OrderData_Schema_Validation"
doc:name="Schema Validation" />
</message-filter>
9/3/2017 Ankit Lawaniya 4
In order to allow a valid XML to pass the filter, you need to set the
returnResult to false in your schema-validation-filter. This way, the payload
of the message that is passed onwards to the next element in your flow will
retain the XML content.
Let’s walk through how to use All Validator in a Mule application. In this
example, we are receiving the XML file through file connector, which will be
validated against an XSD schema file defined in the application. If validation
fails, then we catch the exception and print the "Schema Not Validated"
message along with the exception.
9/3/2017 Ankit Lawaniya 5
9/3/2017 Ankit Lawaniya 6
9/3/2017 Ankit Lawaniya 7
9/3/2017 Ankit Lawaniya 8
9/3/2017 Ankit Lawaniya 9
Now in the XSD XML if we change the any of the element against the schema defined ,we
will be getting the below exception.
ERROR 2017-08-08 21:01:19,585 [[schemavalidation1].SchemaValidationFLow.stage1.02]
org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Message has been rejected by filter.
Filter : org.mule.module.xml.filters.SchemaValidationFilter@39c5e4bb (null)
Payload : <?xml version="1.0" encoding="UTF-8"?>
Element XML : <message-filter throwOnUnaccepted="true" doc:name="Message">
<mulexml:schema-validation-filter
schemaLocations="src/main/resources/File/Process/Schema.xsd" returnResult="true"
name="OrderData_Schema_Validation" doc:name="Schema Validation"></mulexml:schema-
validation-filter>
</message-filter>
Payload Type : org.apache.xerces.dom.DocumentImpl
Element : /SchemaValidationFLow/processors/2 @
schemavalidation1:schemavalidation1.xml:23 (Message)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.routing.filter.FilterUnacceptedException: Message has been rejected by filter.
9/3/2017 Ankit Lawaniya 10
9/3/2017 Ankit Lawaniya 11

More Related Content

Similar to Schema validation filter (xml schema validation)

First successful-router
First successful-routerFirst successful-router
First successful-router
Ankit Lawaniya
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
Son Nguyen
 
Improving performance with cache scope in mule
Improving performance with cache scope in muleImproving performance with cache scope in mule
Improving performance with cache scope in mule
Ankit Lawaniya
 
Elements in a mule flow
Elements in a mule flowElements in a mule flow
Elements in a mule flow
Sindhu VL
 
Mule ESB
Mule ESBMule ESB
Mule ESB
Yura Nosenko
 
Elements in a muleflow
Elements in a muleflowElements in a muleflow
Elements in a muleflow
Thang Loi
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Sreekanth Kondapalli
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
sathyaraj Anand
 
Mule esb presentation 2015
Mule esb presentation 2015Mule esb presentation 2015
Mule esb presentation 2015
Nagesh Penumarthy
 
Email using mule
Email using muleEmail using mule
Email using mule
Manav Prasad
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
RaviShankar Mishra
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
princeirfancivil
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
irfan1008
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Praneethchampion
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
Phaniu
 
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
XML Schema Computations: Schema Compatibility Testing and Subschema ExtractionXML Schema Computations: Schema Compatibility Testing and Subschema Extraction
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
Thomas Lee
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
Anand kalla
 
Spring ws
Spring wsSpring ws
Spring ws
Souleymane MATO
 
InforUMobile SMS API
InforUMobile SMS APIInforUMobile SMS API
InforUMobile SMS API
inforumobile
 
Mule ESB Tutorial Part 2
Mule ESB Tutorial Part 2Mule ESB Tutorial Part 2
Mule ESB Tutorial Part 2Srikanth N
 

Similar to Schema validation filter (xml schema validation) (20)

First successful-router
First successful-routerFirst successful-router
First successful-router
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
 
Improving performance with cache scope in mule
Improving performance with cache scope in muleImproving performance with cache scope in mule
Improving performance with cache scope in mule
 
Elements in a mule flow
Elements in a mule flowElements in a mule flow
Elements in a mule flow
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
Elements in a muleflow
Elements in a muleflowElements in a muleflow
Elements in a muleflow
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Mule esb mule message
Mule esb   mule messageMule esb   mule message
Mule esb mule message
 
Mule esb presentation 2015
Mule esb presentation 2015Mule esb presentation 2015
Mule esb presentation 2015
 
Email using mule
Email using muleEmail using mule
Email using mule
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
XML Schema Computations: Schema Compatibility Testing and Subschema ExtractionXML Schema Computations: Schema Compatibility Testing and Subschema Extraction
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
 
Send email attachment using smtp in mule esb
Send email attachment using smtp  in mule esbSend email attachment using smtp  in mule esb
Send email attachment using smtp in mule esb
 
Spring ws
Spring wsSpring ws
Spring ws
 
InforUMobile SMS API
InforUMobile SMS APIInforUMobile SMS API
InforUMobile SMS API
 
Mule ESB Tutorial Part 2
Mule ESB Tutorial Part 2Mule ESB Tutorial Part 2
Mule ESB Tutorial Part 2
 

More from Ankit Lawaniya

Content based routing using mule choice flow control
Content based routing using mule choice flow controlContent based routing using mule choice flow control
Content based routing using mule choice flow control
Ankit Lawaniya
 
Until successful scope in mule
Until successful scope in muleUntil successful scope in mule
Until successful scope in mule
Ankit Lawaniya
 
Iterative processing using the for each scope in
Iterative processing using the for each scope inIterative processing using the for each scope in
Iterative processing using the for each scope in
Ankit Lawaniya
 
Cors (cross origin request sharing) in mule
Cors (cross origin request sharing) in muleCors (cross origin request sharing) in mule
Cors (cross origin request sharing) in mule
Ankit Lawaniya
 
Content enrichment using mule message enricher
Content enrichment using mule message enricherContent enrichment using mule message enricher
Content enrichment using mule message enricher
Ankit Lawaniya
 
Validation module in mule
Validation module in muleValidation module in mule
Validation module in mule
Ankit Lawaniya
 
Parse template transformer mule
Parse template transformer muleParse template transformer mule
Parse template transformer mule
Ankit Lawaniya
 
Active mq read and write flow in mule
Active mq  read and write flow in muleActive mq  read and write flow in mule
Active mq read and write flow in mule
Ankit Lawaniya
 
Composite source in mule
Composite source in muleComposite source in mule
Composite source in mule
Ankit Lawaniya
 

More from Ankit Lawaniya (9)

Content based routing using mule choice flow control
Content based routing using mule choice flow controlContent based routing using mule choice flow control
Content based routing using mule choice flow control
 
Until successful scope in mule
Until successful scope in muleUntil successful scope in mule
Until successful scope in mule
 
Iterative processing using the for each scope in
Iterative processing using the for each scope inIterative processing using the for each scope in
Iterative processing using the for each scope in
 
Cors (cross origin request sharing) in mule
Cors (cross origin request sharing) in muleCors (cross origin request sharing) in mule
Cors (cross origin request sharing) in mule
 
Content enrichment using mule message enricher
Content enrichment using mule message enricherContent enrichment using mule message enricher
Content enrichment using mule message enricher
 
Validation module in mule
Validation module in muleValidation module in mule
Validation module in mule
 
Parse template transformer mule
Parse template transformer muleParse template transformer mule
Parse template transformer mule
 
Active mq read and write flow in mule
Active mq  read and write flow in muleActive mq  read and write flow in mule
Active mq read and write flow in mule
 
Composite source in mule
Composite source in muleComposite source in mule
Composite source in mule
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 

Recently uploaded (20)

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 

Schema validation filter (xml schema validation)

  • 2. The Schema Validation filter takes XML inputs and validates these against a referenced XSD schema. Typically, we’ll place it at the start of the Mule flow to determine whether the incoming message or event should be handled or not, allowing the message to only continue on along the flow when the filter validations are met and the included XML is considered valid. Schema Validator is provided out of the box with Mule. 9/3/2017 Ankit Lawaniya 2
  • 3. A common use case in Mule ESB flows is validating if an XML document is valid against a corresponding XSD, so we can make sure we are receiving the correct XML, and will forward it for the further processing. Syntax: <mulexml:schema-validation-filter schemaLocations="src/main/resources/File/Process/Schema.xsd" returnResult="true" name="OrderData_Schema_Validation" doc:name="Schema Validation" /> 9/3/2017 Ankit Lawaniya 3
  • 4. The "standard" way of Validating XML schema in Mule is by using the schema-validation-filter and especially in combination with the message- filter. In a case when you want to get an exception and/or call another flow when the validation fails, you could wrap the schema validation filter inside a message filter and then use "onUnaccepted" and "throwOnUnaccepted" configuration attributes to determine the behavior. Here we have wrapped the schema-validation-filter in a message-filter and set throwOnUnaccepted to "true.“ <message-filter throwOnUnaccepted="true" > <mulexml:schema-validation-filter schemaLocations="/File/Process/Schema.xsd" returnResult="true" name="OrderData_Schema_Validation" doc:name="Schema Validation" /> </message-filter> 9/3/2017 Ankit Lawaniya 4
  • 5. In order to allow a valid XML to pass the filter, you need to set the returnResult to false in your schema-validation-filter. This way, the payload of the message that is passed onwards to the next element in your flow will retain the XML content. Let’s walk through how to use All Validator in a Mule application. In this example, we are receiving the XML file through file connector, which will be validated against an XSD schema file defined in the application. If validation fails, then we catch the exception and print the "Schema Not Validated" message along with the exception. 9/3/2017 Ankit Lawaniya 5
  • 10. Now in the XSD XML if we change the any of the element against the schema defined ,we will be getting the below exception. ERROR 2017-08-08 21:01:19,585 [[schemavalidation1].SchemaValidationFLow.stage1.02] org.mule.exception.CatchMessagingExceptionStrategy: ******************************************************************************** Message : Message has been rejected by filter. Filter : org.mule.module.xml.filters.SchemaValidationFilter@39c5e4bb (null) Payload : <?xml version="1.0" encoding="UTF-8"?> Element XML : <message-filter throwOnUnaccepted="true" doc:name="Message"> <mulexml:schema-validation-filter schemaLocations="src/main/resources/File/Process/Schema.xsd" returnResult="true" name="OrderData_Schema_Validation" doc:name="Schema Validation"></mulexml:schema- validation-filter> </message-filter> Payload Type : org.apache.xerces.dom.DocumentImpl Element : /SchemaValidationFLow/processors/2 @ schemavalidation1:schemavalidation1.xml:23 (Message) -------------------------------------------------------------------------------- Root Exception stack trace: org.mule.api.routing.filter.FilterUnacceptedException: Message has been rejected by filter. 9/3/2017 Ankit Lawaniya 10