2

I wonder if there is a way to assert that XML response does NOT contain any other tags than those expected? I am using plain http requests (no WSDL, schema validation, not SOAP, not REST) and the application protocol is custom for a particular application (POS systems).

I was thinking (and started) of creating a custom SOAPUI library with script that contains:

  • a reference table
  • a function that checks if returned tag is on the list (in reference table)
    • if the returned tag is not on the list, then assertion fails

So, my question is: is there a better way to validate that? The response XMLs have a lot of fields, some mandatory, some optional and some conditional depending on other (within same request).

2
  • You can do anything using script assertion. Why don't show the same xml / valid and invalid list to be asserted by updating the question?
    – Rao
    Commented Jun 19, 2016 at 15:07
  • 1
    Create a custom XSD tightly defined to the expected response and execute it using Groovy. community.smartbear.com/t5/SoapUI-NG/… Commented Feb 18, 2017 at 22:10

1 Answer 1

0

If the negative assertions were simple enough I would have suggested using a regex expression. Negative regex expressions are a little trickier than most, and can get ugly fast if you have dependencies between the items you are checking or have a lot of elements to check for/against.

A reference table as you have suggested allows the data to be separated from the code and will allow for easier maintenance.

You can either create a list of expected tags and check that every tag in the response is one of those, or a list of unexpected tags and check that every tag is not one of those. Whichever way you choose should be the one that requires the least maintenance. While the list of acceptable tags may be finite, the list of unacceptable tags may be infinite and you may end up playing whack-a-mole with your dataset by continually adding new tags to disallow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.