Groovy in SOAP UI

Using XPath Assertion in SOAP UI

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.

XPath Match Assertion

XPath Match Assertion

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:

Sample Response

Sample Response

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.

 

(Please feel free to get back if u have any trouble…as i am just a mail away…leave a comment otherwise)

load testing with SOAP request having variable parameter(s)

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.

 

Sample GenReportXml for the above service

Sample GenReportXml for the above service

 

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!
 

SOAP request with in line groovy script

SOAP request with in line groovy script

 

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.

 

(Please feel free to get back if u hav any trouble…as i’m just a mail away..leave a comment otherwise)

 

SOAP UI 2.5 beta-1 is out!

Posted by: devakara on: September 29, 2008

The latest fad from eviware, SOAP UI 2.5 beta-1 is out!

In soapUI 2.5 you will find:

REST/HTTP Support

  - WADL import / export / generation

  - JSON/HTML to XML conversion for assertions, transfers, etc..

  - REST / HTTP Request TestStep

  - Generate both code and documentation for WADLs

WS-Addressing support

  - Request, MockResponse, Assertion

MockService improvements

  - onRequest / afterRequest scripts

  - improved WSDL exposure with ?WSDL endpoint

  - docroot for serving static content

  - HEAD request support

Encrypted Project Files and hidden password fields

LoadTest before/afterRun scripts

Import/Export TestCases/TestSuites for sharing

Relative paths to project resources

Improved SOAP Monitor now supports keep-alive and chunked encoding

Dump-File for response message automatically saves responses to a local file

Unique keystores on request-level

Improved XPath Contains Assertion with option to ignore namespace prefixes

Improved compression algorithm support

Extended HTTP-related settings

And much more …(digg into http://www.soapui.org/new_and_noteworthy_2_5.html)

 

Hopefully seems to have lot of stuff packed to explore…

One can download the beta version from the following link

 

Link to download the beta version