You can use the XML Assertor tool to enforce the correctness of data in an XML message. It is most commonly connected to a SOAP Client or Messaging Client in order to verify the data returned by a service. The XML Assertor provides support for complex message validation needs without the need for scripting and allows you to easily create and maintain validation assertions on your XML messages.

To use the XML Assertor, complete the following:

  1. Right-click the Test 1: getItemByTitle node from the previous exercise and choose Add Output from the shortcut menu.
  2. In the Add Output wizard, choose Response > SOAP Envelope in the left pane and XML Assertor in the right, then click Finish.
  3. In the XML Assertor panel that opens, click the Configuration tab and click Add.
  4. In the Select Assertion wizard, expand Value Assertions, select String Comparison Assertion, then click Next.

    The String Comparison Assertion dialog displays a tree view of the XML message from which you can select a single value to enforce.
  5. Select the name element from the String Comparison Assertion dialog and click Finish.

    The Configuration tab of the XML Assertor is now populated with a String Comparison Assertion.
  6. In the XML Assertor panel, click the Configuration tab.
  7. In the String Comparison Assertion Configuration section, choose contain from the Element must drop-down menu and enter Linux in the Expected Value field.
  8. Save the changes to the XML Assertor Configuration.
  9. Click the Test toolbar button. The test succeeds.

You may add additional assertions to apply to the message (such as a Numeric assertion to enforce on the price element) by clicking the Add button in the XML Assertor’s Configuration tab.

  • No labels