By using a Groovy assertion, you can validate a response against an XSD schema.
Availability
You can run this script as a Groovy assertion.
Example
The following script validates a response against a specified XSD schema:
Groovy
import javax.xml.XMLConstants
import javax.xml.transform.stream.StreamSource
import javax.xml.validation.SchemaFactory
// Specify an XSD Schema
def xsdFilePath = "C:\\temp\\Schema.xsd"
// Get the response as XML
def response = messageExchange.getResponse().contentAsXml
// Create validation objects
def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
def schema = factory.newSchema(new StreamSource(xsdFilePath));
def validator = schema.newValidator();
// Validate the response against the schema
assert validator.validate(new StreamSource(new StringReader(response))) == null;