Mock Web Services
MockServices are displayed in the navigator under their containing project node. They can be
created in a number of ways;
- From the Project popup menu with the "New MockService" action. Creates an empty MockService with no operations.
- From an existing request by selecting the "Create MockResponse" toolbar button which will prompt for which
MockService to add the selected requests operation and current response as a MockResponse.
- From the Interface popup menu with the "Generate MockService" action. This will prompt as follows:

After specifying a path and port to listen on, soapUI will create a MockService with a MockOperation
corresponding to each of the specified interfaces operation. Each MockOperation will further be configured with
a default MockResponse which will be created from the associated WSDL and Schema definition in the same manner as when
importing interfaces and creating requests.
Once created, an arbitrary number of MockOperations can be added to a MockService, there is no requirement
that all operations come from the same interface or that all operations from an interface be mocked. Just
mock those operations that are required.
MockService Actions
Right-clicking a MockService node in the navigator shows a popup menu
with the following actions:
- Show MockService Editor - opens the MockService Editor, see below
- Start Minimized - opens/minimizes the MockService editor and starts the MockService
- Stop - stops the MockService
- New MockOperation - prompts to create a new MockOperation in the MockService
- Clone MockService - clones the entire MockService
- Add Endpoint to Interface - prompts to add this MockServices local endpoint to an Interface in the same project. The
endpoint will be automatically updated if it changed in the MockService Editor.
- Rename - prompts to rename the MockService
- Remove - prompts to remove the MockService
- Online Help - displays this page in an external browser
|
MockService Details Tab
- Name : the name of the MockService
- Description : an arbitrary description of the MockService, displayed as a tooltip over the
MockServices' node in the Navigator.
- Path - the path this MockService listens on (read only)
- Port - the port this MockService listens on (read only)
- Match SOAP Version - controls if incoming requests must match the SOAP Version of
a corresponding MockOperation in a MockService.
- Require SOAP Action - controls if incoming requests SOAPAction must match the SOAPAction of
a corresponding MockOperation in a MockService.
- Dispache Response : enables dispatching of request containing a Response Message instead
of a request.
- Incoming WSS - the Incoming WSS configuration to use for decrypting incoming requests. This is
necessary if the entire body of a message is encrypted since it can not be dispatched otherwise.
- Default Outgoing WSS - the default Outgoing WSS configuration to apply to all MockResponses.
Can be over ridden on the MockResponse level.
The Test Properties tab contains the custom properties defined for this MockService
The MockService Editor
Double-clicking a MockService in the navigator opens the MockService editor as seen to the right.
From the top down the editor has the following parts: A Toolbar with the following options:
- Run - Starts the MockService on the configured path/port and
waits for requests (see below)
- Stop - Stops a running MockService
- Open Interface - Opens an HTML page with links to the currently published WSDL and its parts (see below)
- Options - Opens the MockService Options dialog (see below)
- Help - Opens this page in a browser
The list of MockOperations currently configured for this MockService. Right-clicking
show the MockOperations available actions, double-clicking opens the MockOperation
editor A rolling log of handled requests with a toolbar with the following options:
- Enable - Enables the MockService log
- Clear - Clears all entries from the log
- Options - Prompts for the maximum number of entries to hold in the log. Keep this low as an
entry can take up a fair amount of memory (depending on message size, attachments, etc..)
Double-clicking on an entry in the log displays the entire message exhange for that
request as shown below: |  |

MockService Inspectors
Below the list of MockOperations there are 4 inspectors available (left to right):
- Description : allows you to enter an arbitrary description for the MockService
- Properties : manages custom properties for the MockService
- Start Script : specifies a Groovy Script that should be run when starting the MockService, useful
for initializations, etc...
- Stop Script : specifies a Groovy Script to be run when stopping the MockService, useful for
cleanup, closing connections, etc..
MockService Options
The MockService Options dialog has the following options:
- Path - the local path to mount on
- Port - the port to listen on
- Host - the external IP of the local machine (used for WSDL Publishing)
- Host Only - only bind to host IP instead of all IP's
- Docroot - path to a local folder that should be used to serve files for GET requests to the MockService
path
- Fault Operation - MockOperation to dispatch to if a SOAP Fault message is received by the MockService

MockService execution
When starting the MockService using the Run toolbar button, soapUI starts a local
http server (if not already running for another MockService) as configured in the MockService Options dialog.
This can be seen in the soapUI-log as follows:

SOAP Requests can now be issued to the server from any client as if it were a "real" Web Service, the incoming
requests will be dispatched to the matching MockService / MockOperation which will further dispatch
as configured in Request Dispatching. While
the MockService is running, it is still possible to add/remove MockOperations, MockResponses, etc...
The only values that can not be changed are the path and port of the MockService, for this it
is required to first stop the MockService and then start it again after changing as desired.
If an error occurs during request processing a SOAP Fault will be returned, for example in the following situation
a request was issued from within soapUI that could not be matched to any available MockServices
MockOperation:

WSDL Publishing
When starting a MockService, the corresponding WSDL's and their referenced parts (WSDLs and XSDs) are made available
via a local web interface. All includes/imports are rewritten to references the correct files, and the service port is
changed to the one of the MockService.
The root page of the MockEngine displays a list of running MockServices:

Selecting a MockService displays the Interfaces mocked by it:

Selecting an interface displays the list of parts in the Interface:

... and selecting a part displays it in your browser:

The root WSDL part (displayed first in the list of parts) can be used to generate clients, etc..
As of soapUI 2.5, it is possible to call the MockService path with "?WSDL" which will return the
mocked WSDL directly. If multiple WSDLs are being mocked, soapUI automatically creates a WSDL that
imports these WSDLs instead.
Next:
MockService Coverage