03 December 2007 - 2.0-beta2 |
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:
When properties are expanded, soapUI will look for the named property as follows:
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.
soapUI 1.7.6 introduces rudimentary support for global properties as follows:
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
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"
The table below lists all properties available for property-expansion and property-transfers
TestRequest Step | |
Property | Description |
---|---|
Request | The configures request message |
Response | The last response message (read-only) |
Endpoint | The current endpoint for the request |
Username | The current username for the request |
Password | The current password for the request |
Domain | The current domain for the request |
Properties Step | |
Property | Description |
<any defined property> | the properties' value |
GroovyScript Step | |
Property | Description |
result | the value returned by the script from its last run (read-only) |
DataSource Step (soapUI Pro only) | |
Property | Description |
<any defined property> | the properties' value (read-only) |
MockResponse Step (soapUI Pro only) | |
Property | Description |
Request | The last request message (read-only) |
Response | The configured response message |