Forum Discussion

Department_of_T's avatar
Department_of_T
Contributor
12 years ago

Assertion for a request message[R]

Hi,
Is it possible to validate the request message with assertions?

We have a word document with the requirements for hundreds of messages which contain hundreds of elements. The WSDL may have requests with element names that differ from the requirements word document. This means for each request i will manually enter all the element names i expect to appear in the Request file so i was planning to do a CONTAINS assertion but i have 2 problems

1)The contains assertion only validates the response
2)I cannot enter more than one token (element) in the assertion and i do not wish to create many assertions for all the elements in the message.

eg this is part the WSDL request file in SOAP
<findPermitRequest>
<transactionId></transactionId>
<permitNumber></permitNumber>
<permitKey></permitKey>
</findPermitRequest>

This is the word doc requirement with elements for that request (note, they do not match the request message)
txn id
temp permit number
temp permit key

I wish to add assertions to ensure the elements txn id , temp permit number and temp permit key exist in the REQUEST message.

5 Replies

  • Hi!

    You could also use the Assertion TestStep and the Request property of a TestStep to assert on the request message.

    --
    Regards

    Erik
    SmartBear Sweden
  • Yes, thanks to all.
    This looks promising. I forgot about the Assertion Test Step and was adding Assertions to the Request file.

    I will let you know if it works.
  • 1) I have it working with the XPath assertion but is there a way to assert all the 10+ tags in one assertion? I tried the example below with 2 tags and it fails

    2) I cannot get the Contains Assertion to work. Can anyone offer some advice? I have tried the below content and it always fails
    (?s).(transactionId)
    (?s).(<transactionId)
    (?s).transactionId
    (?s).*transactionId.*

    Thank you in advance.
  • I got it working. Thanks everyone

    (exists(//transactionId) and exists(//vehicleMakeCode) and exists(//vehicleBodyTypeCode))