This is another cool possibility that you can use to streamline your tests, for example you might want to ensure that your service is always returning certain values to a client during a test-scenario. Here the Event Handler functionality in soapUI Pro fits the bill nicely. Open the Project Window and select the Event tab, add a handler for SoapMonitor.afterProxy and set its script as follows:
// get raw response
def str = new String( messageExchange.rawResponseBody )
// replace result
str = str.replaceAll("Result>.*1.0
// save it back
messageExchange.rawResponseBody = str.getBytes()
Now all responses will have a conversion rate of "1.0"
(request with altered response at the top, event handler at bottom left, and SOAP Monitor bottom right)
The beforeProxy event can be used to modify the proxied request instead:
// create string from request
def out = new java.io.ByteArrayOutputStream()
method.requestEntity.writeRequest( out )
// set fixed FromCurrency
def str = out.toString().replaceAll("FromCurrency>.*AUD
method.requestEntity = new org.apache.commons.httpclient.methods.StringRequestEntity( str )
Now all requests will convert from the AUD currency no matter their input.






