Posted by: devakara on: October 3, 2008
Assertions are generally the simple and most sought validations that can be enforced in SOAP UI.
For SOAP response we have an assertion step called ‘XPath Match‘, which validates the value yielded by the specified xpath with the one provided staticly.
When we add ‘XPath Match’ assertion using the Add Assertion button, we see the below window.
There is a button called ‘Declare‘ (present in free version of SOAP UI also), it automatically declares all the namespaces of SOAP response. After declaring the namespaces using this ‘Declare’, mention the xpath of the node whose value is to be validated. Here the xpath could start from the node which comes just after the <soap:Body> node (i.e., <soap:Body> node’s immediate child). For example, if say the response xml is:
then to validate on the value of ‘Status‘ node, the xpath that should be present in XPath Expression blockalong with all the declared namespaces is
//p77:GetReportResponse/p77:GetReport/ReportResponse/Status
And, now we need to provide some expected value, inside ‘Expected Result’ block which shall validated against the corresponding node value. There is an option called ‘Select from current‘, which actually fetches the value of that xpath, from the current response. Another option called ‘Test‘, is used to test right away.
Posted by: devakara on: September 30, 2008
At times there could be requirement of Load Testing a Web Service following different strategies based on the requirement.
But say if there are fields in the SOAP request which are supposed to be unique for every request that hits the service while load testing…really this could be tough to deal with.
With the new feature called in line scripting of SOAP UI 2.5, this could achieved with ease.
For example, lets say we have a web service deployed on a server. And the service writes report files to the server’s file system, with the name having some unique value derived from the SOAP request.
We have a node called RefNum having value 123456 in the above request, using which the service writes a report to the file system with name say Report_123456.txt. Every time a request with some RefNum triggers the service to generate a report file, one hindrance would be the RefNum of every request that hits the servicve should be unique, to have a valid file in the local system.(weird web service right!.. i understand…just take it as an example).
Issue now would be to load test such service, which demands some unique value in the SOAP request evrey time it hits it. In SOAP UI 2.5 we have a very simple solution for such weirdly complicated services, called in-line scripting!
In the above request, under RefNum node I included a Groovy Step to fetch the current time in milliseconds. The notation ${=…} is the next level of Property Expansion technique. The ‘=’ shall evaluate the script and provide the result as that nodes’ value.
This serves the purpose of Load Testing the service, providing unique RefNums for every request, no matter what strategy we follow to in testing, without doing any work around at the application level…(which sounds great!).
The above example seems to be explicitly specific, but I hope it would be usefull. There are still lot of ways we can explore the cool in line Groovy scripting feature , which the SOAP UI’s new version has got along.
Recent Comments