03 December 2007 - 2.0-beta2 home user-guide eclipse jbossws intellij netbeans maven 1.X/2.X PDF files forums bugs sourceforge






Property Expansion

soapUI provides a common ${[testStepName#]propertyName[#xpath-expression]} syntax to dynamically insert values into a number of values during processing. Currently, properties are expanded in:

  • request messages
  • mock response messages (from the MockRunContext see Response Scripts), testStepName is ignored.
  • XPath assertions and their matching values
  • XPath source/target property transfers
  • contains/not-contains content assertions
  • request endpoints
  • custom request/mock-response http headers
  • property-transfer XPath expressions
  • datasource step configuration values (soapUI Pro only)
  • MockResponse step response messages (soapUI Pro only)
  • M

When properties are expanded, soapUI will look for the named property as follows:

  1. if the property contains the name of a TestStep, query that step directly
  2. in the current run/submitcontext where properties can have been set from a groovy-script
  3. in all TestStep properties starting from the current step backwards to the first if the "Search Properties" option has been selected in the TestCase Options dialog)

For example, the following request gets the Author property as described above, either from a proceeding PropertiesStep containing the corresponding property or from the current context set by a preceding Groovy Script:

<ns:Request>
   <ns:Author>${Properties#Author}</ns:Author>
</ns:Request>

Since the value of the property will be set just before it is used, the actual used value will not be seen in the corresponding editors.

If the property expansion further includes an XPath expression, this will be selected from the property value, for example the above example could "extract" the author value from a preceding response with:

<ns:Request>
   <ns:Author>${Search Request#Response#//ns1:Item[1]/n1:Author[1]/text()}</ns:Author>
</ns:Request>

Which would first get the "Response" property of the "Search Request" step and then select the value of the first Items' first Author element. Note that the namespace prefix must match those used in the response message, otherwise the expansion will fail.

Property Transfers are a more tedious way of accomplishing the same functionality as with property-expansion. On the other hand, property transfers provide the possibility to transfer complex content between request/response messages. Also, the result of a Property Transfer is visible directly in the corresponding request/response editors.

Global Properties

soapUI 1.7.6 introduces rudimentary support for global properties as follows:

  • Specify a global properties file at the command-line by adding a -Dsoapui.properties argument in the soapui.bat/.sh file
  • Refer to properties in this file using a ${##property.name} syntax

The specified file will be read the first time a global property is referenced. If the specified property is not available or no file has been specified, the corresponding System Property will be returned instead if available

For example, create a properties-file named "properties.txt" containing

test.a.property=hello!

in the soapUI bin folder. Modify the java arguments in the soapUI.bat file to be

set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -Dsoapui.properties=properties.txt

Add the following expansion to a TestRequest/Endpoint/etc..

${##test.a.property}

When expanded, the specified properties file will be loaded as shown in the soapUI log:

01:20:05,234 INFO  [PropertyExpansionRequestFilter] Loaded 52 properties from [C:\workspace\core\project.properties]

This feature can be especially useful when wanting to specify global endpoints/authentication settings, just specify the corresponding expansions in the endpoint/authentications properties and they will get expanded when used

Nested Properties

soapUI supports both nested and recursive property-expansion (be careful!), for example:

test = "value"
testexp = "${test}" 

-> "${testexp}" evaluates to "value"
testexp = "value"
exp = "${exp}" 

-> "${test${exp}}" evaluates to "value"
testxml = "<test><value id="123">hello</value></test>"
testxpath = "//value[@id=${id}]/text()"
id = "123"

-> "${#testxml#${testxpath}}" evaluates to "hello"

Available Properties

The table below lists all properties available for property-expansion and property-transfers

TestRequest Step

PropertyDescription
RequestThe configures request message
ResponseThe last response message (read-only)
EndpointThe current endpoint for the request
UsernameThe current username for the request
PasswordThe current password for the request
DomainThe current domain for the request

Properties Step

PropertyDescription
<any defined property>the properties' value

GroovyScript Step

PropertyDescription
resultthe value returned by the script from its last run (read-only)

DataSource Step (soapUI Pro only)

PropertyDescription
<any defined property>the properties' value (read-only)

MockResponse Step (soapUI Pro only)

PropertyDescription
RequestThe last request message (read-only)
ResponseThe configured response message


Next: LoadTesting