ValueTransfers

ValueTransfers are TestCase steps that transfer values from a message response to the following request message. They hold an arbitrary number of "value transfers", each containing a source and destination xpath expressions.

ValueTransfers use the same Saxon XPath engine as described for the XPath Assertion.

Transfer Execution

Upon execution during a TestCase run, each transfer in the ValueTransfer is performed by selecting the node specified by the transfers source xpath expression from the preceding response message and copying that value to the destination xpath applied to the subsequent TestRequests request message.

The source and target xpath expressions must both point to existing nodes in their respective messages, the response message obviously requires the node so it can be selected, the request message requires the node so it can be found and overwritten with the value copied from the preceding request message.

The nodes selected by the source/target expressions must be assignable; they must either be of the same type (ie both are elements, attributes, etc) or of different types that could be assignable (ie a text() source to a @attribute destination). The transfer implementation will do its best to copy nodes of different types.

If any of the transfers fail due to missing matches of any of the xpath expresion, an error is printed and that transfer is ignored. The TestCase run is not aborted.

The ValueTransfer Editor

The ValueTransfer editor is opened by double-clicking a ValueTransfer test step either in the navigator or in the TestCase editors test-step-list.

The editor contains a list of configured transfers to the left, selecting a transfer in the list will displays that transfers source and destination xpath expressions to the right.

The following actions are available from the bottom toolbar

  • Add : prompts to add a new transfer to the list
  • Copy : prompts to create a copy of the selected transfer
  • Delete : prompts to delete the selected transfer
  • Declare : declares namespaces in both the source and destination xpath fields. Namespaces in the source field are extracted from the preceding TestRequests current response message (if available). Namespaces in the target field are extracted from the subsequent TestRequests request message (if availabele).
  • Run : runs the transfers, ie transfers the values specified. For this to work a response message must be available for the preceding TestRequest.
  • Close : closes the dialog

Working with ValueTransfers

A ValueTransfer can be created as follows:

  1. Begin by creating the two Request Steps that the ValueTransfer should transfer between and submit the first request so you have a response to test your transfers on
  2. Create the ValueTransfer and add a first transfer in the configuration dialog using the Add button
  3. Proceed by defining namespaces in the xpath expressions using the Define button
  4. Now add the actual xpath expressions that specify what to select and where to copy it. In the screenshot above both expressios 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 preferrably 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

ValueTransfer 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/2005-09-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/2005-09-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 result to the author request element in the following request;

Source XPath:

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

Target XPath:

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


Next: CommanLine tools