Schema Validation In Mule 4

DZone 's Guide to

Schema Validation In Mule 4

In this article, see what a schema validation in Mule 4 looks like.

· Integration Zone ·
Free Resource

Close up of a mule's eye

What Is a Schema Validation Filter?

The Schema Validation component takes XML inputs and approves these against a referenced XSD pattern.

Ordinarily, you can put this component before another message processor, for example, a connector, to decide if the approaching message or occasion ought to be dealt with or not, enabling the message to possibly proceed along the stream when the channel approvals are met and the included XML is viewed as legitimate.

Basic Configuration: 

  • Path to XSD schema location.
  • The Schema Validation Filter utilizes the JAXP libraries to approve a message against a pattern. You should give the way, record name, and expansion of the outline or constructions in the Schema Locations property. 
  • Alternatively, you can set Schema Language to the pattern language to utilize. If not indicated, the property defaults to XML Schema. 
  • For the situation you need to get an exemption or potentially call another stream when the approval comes up short, you could wrap the construction approval channel inside a message channel and afterward use "on Unaccepted" and "throwOnUnaccepted" setup ascribes to determinate the conduct.
You might also be interested in:  Mule 4: JSON Schema Validation

Example of Schema Validation in Mule 4

See how to validate an XML payload using the Schema validation component.

Please follow the below steps:

Step 1:

Create a new Mule Project as XML_Schema_Validation    

Step 2:

Intuitive an HTTP listener connector to get a solicitation for your servers and give the host and port numbers. Here, the host is set to localhost and port to 8081. Test your association and check if the port is being used or not and test it effectively.

Step 3:

Set the path as  /schema.

Step 4:

Drag the schema validator Component


Step 5:

Select the schema language and add module configuration also.

NOTE: Example for X12 Schema:

The schema is in the form of (file.xsd) extension


Step 6:

Drag the logger component and check the payload and whether the validation is successful or not.                                

Step 7:

Run the project

Step 8:

Open the postman and hit your service URL request as shown.  http://localhost:8081/schema

Input payload:


Step 9:

Our Output Payload as 

Now, we look about the entire flow of a Mule project i.e XML schema validation. 

NOTE: Entire code of the example:



Mule 4 accompanies several upgrades and improvements. Validate schema component in Mule 3 was different compared to Mule 4, and it has been rearranged for developers. In this way, it is simple to execute and gives some additional highlights.

Further Reading

Validate JSON Schema Components in Mule

How to Use Validate JSON Schema and Message Enricher in Mule

integration, mule, mule 4, schema validation, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}