Forum Discussion

groovyguy's avatar
groovyguy
Champion Level 1
7 years ago
Solved

Validate String in Groovy

I have a series of scripts that run and do the following:

  1. Create Null Test Steps
    1. 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.
  2. Script Assertion to verify the request is schema valid. Only works if ran against a virt or actual web service.
  3. 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.

26 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    How about using "Schema compliance" assertion for "Soap Request" test step?
    • groovyguy's avatar
      groovyguy
      Champion Level 1

      That's something I can take a look at, and I'll admit I wasn't aware there was a schema compliance assertion for requests. Ultimately what I'd like to do is to check an XML request I have generated into a string in my groovy script against the wsdl/schema.

       

      I'll check out that assertion though and see if it helps. 

      • nmrao's avatar
        nmrao
        Champion Level 3
        Sorry, I take it back. I thought your question was to apply validation on the response. Looks you want to do it on request.

        If you are ok, there is a preference which does the validation for each output request. But, that may be a set back, becuase, you want to try negative condition ie.., send invalid request and see how server side validations in place.