Custom Event Handlers

This page contains information on standalone SoapUI Pro that has been replaced with ReadyAPI.
To try enhanced event handling functionality, feel free to download a SoapUI Pro trial from our website.

soapUI 3.0 Pro introduces powerful event-handling functionality which makes it easy to attach custom scripts to test-execution-related events in soapUI. Possible usage scenarios are:

  • Modification of outgoing requests (changing namespaces, adding security tokens, etc..)
  • Filtering of requests handled by the SOAP Monitor (adding/changing content, etc)
  • Custom logging of results during loadtests, testsuites
  • Custom handling of requests to MockServices
  • etc...

The Event Handlers tab in the Project Window is as follows:


The table at the top lists all handlers and contains a toolbar for adding/removing new handlers. The columns in the table are:

  • Name : an arbitrary name for the handler
  • Event : for which event the handler will be triggered
  • Target : an regex filter expression that will be applied for the corresponding target object when the event is triggered. Use this to narrow down invocations. This field can also contain property-expansions (see more below)
  • Disabled : option to temporarily disable an event handler

Selecting an entry will enable the script editor at the bottom allowing you to enter the desired script

Event Filtering

As mentioned above, the target column can be used to filter out which target items a script should be applied to, for example for a TestRunListener.afterTestStep script, you could enter "Request.*" to narrow the script down to all steps beginning with the letter "Request".

The target also support property-expansion, and if this returns a boolean string "true" or "false", this value will be used (true will apply the filter, false will not). When using this with the script-property-expansion feature, you can for example enter as follows in an TestRunListener.afterTestStep target:

${=testStepResult.timeTaken > 50}

This would evaluate the script and return "true" for those teststeps having taken more than 50 ms, thus applying the script only to them.

Available Events

When adding a new handler, you will be prompted for which event to handle:


Getting to know the available events is basically knowledge of the soapUI API, the following Listeners are currently exposed with their corresponding methods:

  • SubmitListener : events related to submits of a request (both SOAP and REST)
  • RequestFilter : events related to sending a request (both SOAP and REST)
  • ProjectRunListener : events related to running tests at the Project level
  • TestSuiteRunListener : events related to running tests at the TestSuite level
  • TestRunListener : events related to running tests at the TestCase level
  • LoadTestRunListener : events related to running LoadTests
  • MockRunListener : events related to a MockService and its dispatching
  • MonitorListener : events related to handling of messages via the SOAP Monitor