Book Image

Spring Integration Essentials

By : CHANDAN K PANDEY
Book Image

Spring Integration Essentials

By: CHANDAN K PANDEY

Overview of this book

Table of Contents (18 chapters)
Spring Integration Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Validating XML messages


While we are discussing XML transformation, it's relevant to bring up the validation aspect of the XML payload. Prevalidation of XML will save the system from going in an erroneous condition and can act at the source. Spring Integration provides support for XML validation via a filter:

<int-xml:validating-filter 
  id="feedXMLValidator" 
  input-channel="feedsReadChannel" 
  output-channel="feedsWriteChannel" 
  discard-channel="invalidFeedReads" 
  schema-location="classpath:xsd/feeds.xsd" />

The schema-location element defines the XSD that should be used for validation. This is optional and if it has not done so, set it to default xml-schema, which internally translates to org.springframework.xml.validation.XmlValidatorFactory#SCHEMA_W3C_XML.

We discussed a lot of inbuilt transformers, primarily dealing with XML payloads. Apart from these, Spring Integration provides many out-of-the-box transformers for the most common conversions, such as:

  • object-to-string-transformer...