Interview Questions

How to change response before it gets validated ?

SoapUI FAQ


(Continued from previous question...)

How to change response before it gets validated ?

For example if you want to change all 555 to 444 in all response messages, proper way is to use RequestFilter.afterRequest event handler and add script:

01.if( request.response == null )
02. return
03.
04.// get response content
05.def content = context.httpResponse.responseContent
06.
07.// manipulate content
08.content = content.replaceAll( "555", "444" )
09.
10.// write it back
11.context.httpResponse.responseContent = content

(Continued on next question...)

Other Interview Questions