15 January 2008 - 2.0.1 home user-guide eclipse intellij netbeans maven PDF files forums bugs sourceforge eviware.com






Property Transfers

Property Transfers are TestSteps that transfer properties between Property Containers within the same scope as the PropertyTransfer TestStep (ie its containing TestCase, TestSuite, Project and Goal Properties). The step can contain an arbitrary number of "transfers" specifying a source and destination property with optional XPath/XQuery expressions.

Property Transfers use the same Saxon XPath/XQuery engine as described for the XPath/XQuery Assertion.

The PropertyTransfer Editor

The Property Transfer editor is opened by double-clicking a PropertyTransfer step either in the navigator or in the TestCase editors' TestStep-list.

The editor contains a list of configured transfers to the left, selecting a transfer in the list will display that transfers source and destination XPath/XQuery expressions to the right.

Use the top-right ComboBoxes to specify the source/property to be transferred, the target/property is specified with the combo-boxes in the middle. If the properties contain XML an accompanying XPath expression can be specified to further select the value to transfer from/to. soapUI Pro adds an XPath Selector button to the right of these combo boxes for easily selecting the source/target XPath expression from the selected source/target property.

The following actions are available from the top toolbar

  • Add : prompts to add a new transfer to the list
  • Delete : prompts to delete the selected transfer
  • Copy : prompts to create a copy of the selected transfer
  • Rename : prompts to rename the selected transfer
  • Run : runs the selected transfer, i.e. transfers its value as configured specified. For this to work properly the source and target properties must be available (for example a TestRequest response).
  • Run All : runs all the transfers, i.e. transfers the values specified. For this to work properly the source and target properties must be available (for example a TestRequest response).
  • Declare : declares namespaces in both the source and destination XPath fields. Namespaces in the source field are extracted from the selected TestRequests current response message, namespaces in the target field are extracted from the subsequent TestRequests request message. If either of these are not available, soapUI will prompt to define all namespaces available in the associated schemas.
  • Online Help - Displays this page in an external browser

A "Transfer Log" inspector at the bottom of the editor displays all transfers performed by this PropertyTransfer while the editor has been open, including both those performed using one of the toolbar buttons and those performed during a TestCase/TestSuite run. The Transfer Logs toolbar contains a "Clear" button to clear its current contents.

Transfer Execution

Upon execution during a TestCase run, each transfer in the Property Transfer is performed by selecting the property specified by the transfers source step, property and optional XPath expression and copying their value(s) to the destination steps specified property using an optional XPath expression.

If XPath expressions are specified, soapUI will try to replace the target node with the source node if they are of the same type. If not (for example when assigning text() to an @attribute), soapUI will do its best to copy the value as possible.

Source and target XPath expressions must both point to existing nodes in their respective properties, the source property obviously requires the node so it can be selected, the target property requires the node so it can be found and overwritten.

If any of the transfers fail due to missing matches of any of the XPath expression, an error is printed and the step will either fail or go on, depending on of the "fail on error" option has been selected for that transfer. TestCase execution is only aborted if the TestCases' "Fail on error" option has been set as described for under TestCase Options.

The following options are available for each transfer:

  • Fail transfer on error - Fails the property-transfer if an error occurs (for example a missing source property)
  • Set null on missing source - Overrides errors for missing source values and sets the target property to null in these cases
  • Transfer text content - When the XPath expression point at element nodes, their text content is transferred instead of the elements themselves (required for backward compatibility with soapUI 1.5)
  • Ignore empty/missing values - Overrides errors for missing source values and just ignores corresponding transfers
  • Transfer to all - If the target XPath expression selects multiple nodes, the source property value will be set in all these nodes instead of only the first one.
  • Use XQuery - interprets the specified source XPath expression as an XQuery expression instead, allowing for transfers of complex/transformed data instead of just "plain" copying

Working with Property Transfers

A Property Transfer can be created as follows:

  1. Begin by creating the two TestSteps that the PropertyTransfer should transfer between.
  2. Create the PropertyTransfer and first add a transfer in the configuration dialog using the Add button
  3. Select the source and target TestStep and property in their respective combo-boxes
  4. If any of the properties contains XML, proceed by defining namespaces in the XPath expressions using the Define button, then add the actual XPath expressions that specify what to select and where to copy it. In the screenshot above both expressions are //ns1:SessionId which will result in the sessionID element being copied from the preceding response to the following request (where it must be available but preferably empty)
  5. Test the transfer(s) by selecting the Run button and check the following request message that the values have been copies correctly. Any errors will be shown either in the main soapUI log (at the bottom) or in a designated popup
  6. Repeat steps 3-5 for each transfer added to the ValueTransfer

with soapUI Pro creating property transfers is greatly simplified using the corresponding Response Wizards which perform most of the above steps automatically.

PropertyTransfer Example

The following sample is also included in the sample project included in the offline distribution:

Set up 2 requests to the Amazon Web Service defined at (http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl);

<soapenv:Envelope xmlns:ns="http://webservices.amazon.com/AWSECommerceService/2006-02-15" 
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
     <ns:ItemSearch>
        <ns:SubscriptionId>- your subscription id here-</ns:SubscriptionId>
        <ns:Request>
           <ns:SearchIndex>Books</ns:SearchIndex>
           <ns:Title>Oxford</ns:Title>
        </ns:Request>
     </ns:ItemSearch>
  </soapenv:Body>
</soapenv:Envelope>

and

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
	xmlns:ns="http://webservices.amazon.com/AWSECommerceService/2006-02-15">
  <soapenv:Body>
     <ns:ItemSearch>
        <ns:SubscriptionId>- your subscription id here -</ns:SubscriptionId>
        <ns:Request>
           <ns:Author>?</ns:Author>
       <ns:SearchIndex>Books</ns:SearchIndex>
        </ns:Request>
     </ns:ItemSearch>
  </soapenv:Body>
</soapenv:Envelope>

and then create the following transfer which moves the first author from the first requests "response" property to the author request element in the following steps "request" property;

Source XPath:

declare namespace ns='http://webservices.amazon.com/AWSECommerceService/2006-02-15';
(//ns:Author)[1]

Target XPath:

declare namespace ns='http://webservices.amazon.com/AWSECommerceService/2006-02-15';
(//ns:Author)[1]


Next: Conditional Goto Steps