cancel
Showing results for 
Search instead for 
Did you mean: 

Logging a mock service response

SOLVED
Frequent Contributor

Logging a mock service response

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Logging a mock service response

Hey, simply use:

 

log.info mockResult.getResponseContent()

Check https://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/mock/RestMockResult.html



If my answer helped please click on the 'Accept as Solution' button.
2 REPLIES 2
Highlighted
Community Hero

Re: Logging a mock service response

Hey, simply use:

 

log.info mockResult.getResponseContent()

Check https://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/mock/RestMockResult.html



If my answer helped please click on the 'Accept as Solution' button.
Frequent Contributor

Re: Logging a mock service response

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

 

New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors