Dear colleagues,
I would like to log requests and responses from within the SoapUI mock service in order to see what has been sent to the mock service and what the mock service responded.
I have created a script and put it into "AfterRequest Script" of the mock service.
I am logging the request by:
mockResult.getMockRequest().getRequestContent()
and response by:
mockResult.getMockResponse().getResponseContent()
However, the content of the response is only the response template, before parameter expansion, i.e. contains <id>${=java.util.UUID.randomUUID()}</id> etc.
How can I log the exact response which has been sent out to the service consumer? I went through the SoapUI 5.4.1 API, but was not able to find the way.
Solved! Go to Solution.
Hey, simply use:
log.info mockResult.getResponseContent()
Check https://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/mock/RestMockResult.html
Hey, simply use:
log.info mockResult.getResponseContent()
Check https://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/mock/RestMockResult.html
Great, thanks a lot.
Interesting, this code writes down the response content before parameter expansion:
log.info mockResult.getMockResponse().getResponseContent()
And this line of code gives the response content after parameter expansion:
log.info mockResult.getResponseContent()
Best regards,
Karel