Show List
Capture SOAP Service Request Response Using WireMock and Postman
WireMock can be used as a web server that can serve mocked response to incoming requests. In this tutorial we will see how to use WireMock to capture SOAP requests and response and to serve the mock response.
Start the WireMock stand alone server on port 9999 as explained in this tutorial.
Access WireMock Recorder
WireMock recorder can be accessed from the browser using the server port number http://localhost:9999/__admin/recorder/
The recorder is used to capture the requests and responses from the actual API.
Capturing Requests and Responses
For this demo we are going to use the public SOAP service from below website :
https://www.dataaccess.com/webservicesserver/NumberConversion.wso?op=NumberToWords
Based on the information provided on the website below is a sample call to this SOAP Web Service from Postman.
Below are the headers for this request:
Now we are going to mock this request and response so that we get the same response from WireMock server by going to the end point "http://localhost:9999/webservicesserver/NumberConversion.wso" instead of going to the real API end point "https://www.dataaccess.com/webservicesserver/NumberConversion.wso".
To do this, first we have to capture the request and response in WireMock. On the WireMock recorder page, enter the target url (of the real API) and click on "Record" button. "Recording" status will show as below:
On the Postman, change the end point host to "http://localhost:9999" so that the request goes through WireMock server. When "Send" button is clicked, the response would display and both request and response get captured in WireMock.
Click on the stop button on the WireMock recorder. It will display the count of captured requests:
The captured stub can be found in the "mappings" folder:
Playing Back the Recorded Requests
Now we can stop the real SpringBoot API as the request and response have been captured in the WireMock server and it can use that to serve the request.
Call the endpoint with WireMock host to see the recorded response:
Leave a Comment