Adding contain verification points
With contain verification points, you can check that one or several elements of the XML content returned by a service match the XML fragment that is specified in the verification point.
- Contain verification points return a Pass status when the response XML contents contain the expected XML fragment.
- Equal verification points return a Pass status when the response XML contents match exactly the entire expected XML content.
Complex service requests or verification points might have empty XML elements that are not needed in a test script. When playing back the test, you can skip such empty XML elements. In ensure that the Display the 'Skip if empty' column in XML tree viewer check box is selected. This option displays a Skip if empty column in the tree view of the request. You can then choose the XML elements to skip.
You can use a contain verification point to check that
the message response contains only a specific element with a specific
value. For example, consider the following message response:
<s:Envelope
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action
s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
<a:RelatesTo>uuid:ed9bc447-d739-452f-989d-cd48344d494a</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value
xmlns:a="http://schemas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text
xml:lang="en-US">The message could not be processed. This is most likely because the action 'http://Samples.ICalculator/Add' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.</s:Text>
</s:Reason>
<s:Node>http://www.w3.org/1999/xlink</s:Node>
<s:Role>http://www.w3.org/1999/xlink</s:Role>
<s:Detail
xmlns:tns0="http://schemas.com/2003/10/Serialization/"
xmlns:tns15="http://Samples.Windows"
tns0:Id="id"
tns0:Ref="idref">
<tns15:GetCallerIdentityResponse>
<tns15:GetCallerIdentityResult>str</tns15:GetCallerIdentityResult>
</tns15:GetCallerIdentityResponse>
</s:Detail>
</s:Fault>
</s:Body>
</s:Envelope>To check for the
Subcode element,
the expected content of the contain verification point is the following
XML fragment:<s:Subcode
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Value
xmlns:a="http://schemas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</s:Value>
</s:Subcode>By default, the contain verification
point checks whether an element named
Subcode contains
one element named Value. You can use the following
options:- Test using XML namespaces: With this option,
the verification point checks whether an element named
"http://www.w3.org/2003/05/soap-envelope":SubCodecontains one element named"http://www.w3.org/2003/05/soap-envelope":Value. - Test XML text node: With this option, the
verification point also checks whether the element named
Valuecontains the texta:BadContextToken. - Test XML attributes: With this option,
the verification point also checks that the attributes match the expected
XML fragment. In this example, the Test XML attributes option
is not necessary because the
Subcodeelement does not have any attributes.
To check that the
Detail element properly
returns a specific value for GetCallerIdentityResult,
the expected content of the contain verification point is the following
XML fragment:<s:Detail
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:tns0="http://schemas.com/2003/10/Serialization/"
xmlns:tns15="http://Samples.Windows"
tns0:Id="regular_expression"
tns0:Ref="idref">
<tns15:GetCallerIdentityResponse>
<tns15:GetCallerIdentityResult>IdentityValue</tns15:GetCallerIdentityResult>
</tns15:GetCallerIdentityResponse>
</s:Detail>You can use the following options:- Test XML text node: With this option, the
verification point also checks whether the element named
GetCallerIdentityResultcontains the textIdentityValue. - Test XML attributes: With this option,
the verification point also checks that the attribute
Idreferred to bytns0:Idhas the expected value. You can specify a regular expression for this value by using the Regular expression column in the Tree view of the verification point. For example,tns0:Id="[a-zA-Z]"checks that the value does not contains numbers.