Forum Discussion

marlonumali's avatar
marlonumali
Occasional Contributor
7 years ago

How to validate request message against an xsd file in ServiceV Virt Assertion

I' m trying to validate request message sent to our Virt Server but has not succeeded yet. I'm using the following script which works in SoapUI Test Step Assertion for response message.

 

def xsd1= new StreamSource(new FileInputStream("C:\\Projects\\xsd\\xsd1.xsd"))
def xsd2= new StreamSource(new FileInputStream("C:\\Projects\\xsd\\xsd2.xsd"))

StreamSource[] schemaFiles = [xsd1,xsd2];

def factory = XMLSchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
def schema = factory.newSchema(schemaFiles)
def validator = schema.newValidator()

validator.validate(new StreamSource(new StringReader(messageExchange.requestContentAsXml)))

 

This script when run gives an error "cvc-elt.1: Cannot find the declaration of element soapenv:Envelope".

 

My goal is just to validate the data type of the element and attribute values that are sent in a Message Request which the built in "Schema Compliance" assertion does not seem to check as stated in "https://support.smartbear.com/readyapi/docs/testing/assertions/reference/compliance/schema-compliance.html".

 

I appreciate any help or advice the community may give. Thank you.

No RepliesBe the first to reply