groovyguy
8 years agoCommunity Hero
Validate String in Groovy
I have a series of scripts that run and do the following:
- Create Null Test Steps
- Parse an entire existing SOAP test step and use groovy to build what we call NULL tests. This takes every field and builds a test step where it is either empty or missing.
- Script Assertion to verify the request is schema valid. Only works if ran against a virt or actual web service.
- Script Test step to delete any schema invalid requests where the wsdl/schema do not allow an element to be an empty string or be missing.
What I'd like to do is to build a way into the first groovy script to compare the string content of the new request to be made for schema validity. This would cut out the need for the other two scripts.
I have yet to figure out how, if it's even possible, to compare an XML string against the wsdl/schema in ReadyAPI to see if it's a valid request. Has anyone done that previously? It'd help me expand on my groovy scripting to learn.
- groovyguy,
Ok, finally I could dig out the script to validate.
Please find the script below.
https://github.com/nmrao/groovyScripts/blob/master/xml/ValidateXmlAgainstXsd.groovy
Let me know if the same helps or not.