Sometimes, a response received from the web service under test contains data that changes from one method call to another even if the parameters passed to the same method being called are not changed. For example, such a response may contain the date and time of the method call or some identifiers and information on security tokens that change from one method call to another.
This especially concerns methods of WCF services that transfer encrypted and signed data and use various security mechanisms. In this case, SOAP responses obtained from a WCF service often contain Header elements with a lot of security-related data that changes from one method call to another and do not contain actual results returned by the called method (these results are included in Body elements).
Such variable data in a web service’s response may cause a failure of a web service checkpoint even if the latter checks results obtained from the same method with the same parameters passed to it.
Therefore, in order to successfully check the needed web service method, checkpoints should ignore variable data in responses.
To exclude such data from verification, delete them from the XMLCheckpoint element that stores the expected response data:
Open the XMLCheckpoint element storing desired response data in the XMLCheckpoint Element editor.
In the Tree View page, delete XML nodes that should be ignored during verification.
Enable the Compare in subtree mode checkpoint setting.
TestComplete will check whether nodes stored in the XMLCheckpoint element are included in the actual response and then will check values of those nodes. If a node exists only in the actual document, it is excluded from verification.
Tips on Excluding Variable Data
To exclude variable data from verification of a web service’s responses, follow the recommendations below:
If you test a WCF service that transfers data in the security mode and passes a lot of variable data within the Header element of a SOAP response, you can completely remove this element from an XML document stored in your XMLCheckpoint item and enable the Compare in subtree mode option in the properties of the checkpoint. In this case, the checkpoint will not use the Header element when comparing XML documents. It will compare only results returned by the web service method and contained in the response’s body (the Body element).
If you do not want to remove the whole Header element as it was described above or if your SOAP response contains some variable data in another element of the checkpoint’s XML document (you can easily explore this document in the XMLCheckpoint Element editor), you can remove the needed element with the variable data from the baseline copy of the response and enable the Compare in subtree mode option in the same manner as described above.
If the service’s response contains variable data only in some attributes of elements in the XML document (not within elements’ bodies) and there is no need to compare particular attribute values in your service’s responses, you can simply enable the Ignore attributes option in the properties of the XMLCheckpoint element. In this case, the checkpoint will ignore all attribute values in responses during the comparison.
Note that you can edit the baseline copy of the service’s response stored in an XMLCheckpoint element either visually at design time, by using the XMLCheckpoint Element editor, or programmatically from scripts or keyword tests at run time, by using the
XMLCheckpoint object. For more information on this, see Modifying Elements of the XML Collection.