Prepare test case in SoapUI using SQL script and custom properties

When prepare test case in SOAPUI, you might need to select a bunch of data from database to create your test cases. This can be done by using JDBC request as test steps in SoapUI.

The next step is to save script result (data set) in properties that can be retrieved by other test steps for example SOAP request. But how to extract values from result xml and save as string list? Assume we need to read MEM101_PMEIDE field from above sample.

Here is the answer. We can add a new property transfer step in SoapUI. Use XQuery script to read MEM101_PMEIDE field from xml.

XQuery script:

for $id in //Results[1]/ResultSet[1]/Row/MEM101_PMEIDE
return string($id)

The output result: “1002016138 1002016139 1002012384 1002012385 1002005752 1002005753 1002004372 1002004373” will be saved into properties where you defined as target.

Almost there! As SQL script returns a list of member then we will read each individual member from list and populate them into SOAP request.

Groovy script: ${=testSuite.getPropertyValue(“planMemberReference-WS04”).tokenize(‘ ‘)[0]} utilize tokenize function that returns the first member in the list.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s