08 May 2007 - 1.7.1 |
A MockOperation corresponds to an operation in one of the current projects interfaces and will dispatch incoming requests if they match the operations SOAP Action and arguments. A MockOperation contains a variable number of MockResponses that contain actual response messages to be returned to a caller. Dispatching of requests to a specific MockResponse can be done in a number of ways as described below.
Right-clicking a MockOperation node in the navigator or MockService editor shows a popup menu
with the following actions:
| ![]() |
The bottom left details tab for a MockService displays the following properties:
| ![]() |
Double-clicking a MockOperation in the navigator opens the MockOperation editor as seen below. From the top down the editor has the following parts:
A Toolbar with the following options:
The list of MockResponse currently configured for this MockOperation. Right-clicking show the MockResponses' available actions, double-clicking opens the MockResponse editor
A Dispatch Toolbar and configuration are below whose content depends on the selected dispatch style (see below)
Incoming requests to a MockOperation can be dispatched in one of 4 ways using the dispath combo-box:
Both the XPath and Script dispath methods allow specification of a default response to be returned if there is no matching response for the XPath or script expression. When selecting XPath or Script, a corresponding editor is shown below the dispatch toolbar where the XPath expression or groovy script can be entered and tested. When running soapUI Pro, the XPath editor also includes a button for the XPath Selector.
Using groovy scripts as a controller to dispatch incoming is a very flexible way of creating MockOperations. The script has access to the following variables:
The script has access to the following objects:
context
- an instance of
MockRunContext
that can hold dynamically user-defined properties. The context is service scoped, ie shared between
all MockOperations/MockResponses for a MockService during its lifetime. Since this object implements the Map
interface
it can be accessed using groovy's built-in collection support (see example screenshot below)mockRequest
- an instance of
WsdlMockRequest
which provides access to request-related objects, including the underlying HttpServletRequest/HttpServletResponse objectsmockResponse
- an instance of
WsdlMockResponse
which provides access to the current MockResponse object (for example for dynamic manipulation of attachments)log
- a standard log4j Logger that logs to the groovy log tabThe script must return the name of the MockResponse to dispatch to, ie the script shown in the screenshot above always dispatches to a MockResponse named "Response 1"