I'm developing aplication which sends thousands of http post requests. I want to record all responses and use them as stubs with help of Fiddler`.
For example (lets assume product price = productid for simplicity):
- send request, body
<productId>1</productId> - get real response, body
<productprice>1</productprice> - save response (headers+body) form previous step in local storage,for
example in some dictionary
[1,"HTTP/1.1 200 OK <productprice>1</productprice>"]. (Since we stored this response, next requests matching patternbody contains <productId>1</productId>should be responded from our local storage ) - send request, body
<productId>1</productId> - load response from local storage and return
HTTP/1.1 200 OK <productprice>1</productprice> - send request, body
<productId>2</productId> - get real response, body
<productprice>5</productprice> - save response (headers+body) form previous step in local storage,for
example in some dictionary
[1,"HTTP/1.1 200 OK <productprice>1</productprice>"],[2,"HTTP/1.1 200 OK <productprice>2</productprice>"] - ...
How to configure Fiddler for it?
Details:
I have already captured 1000 real POST requests and i want to debug my application with help of them.
Each request / response is unique and in general looks like:
request
POST https://myurl HTTP/1.1
Authorization: Bearer xxx
Content-Type: application/soap+xml; charset=utf-8; action="GetList"
Host: myurl.net
Content-Length: 358
Expect: 100-continue
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<catalogRequest xmlns="https://myurl">
<id xmlns="">1</id>
</catalogRequest>
</s:Body>
</s:Envelope>
response
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="https://myurl">
<env:Body>
<ns1:catalogResponse>
<result>
<id>1</id>
<name>some text</name>
<price>109.99</price>
... big xml ...
<status>1</status>
</result>
</ns1:catalogResponse>
</env:Body>
</env:Envelope>
I tried Autoresponder, but when i dragged captured sessions to the Autoresponder they were converted to rules like: METHOD:POST EXACT: - this rule doesn't use POST body. I can't manually change 1000 rules to use URLWithBody rule
I think it is possible to create Fiddler script, but i don't know how to store captured requests/responses for this script to use them as mapping.
After small research i found a way to record responses and use them as stubs in future. To acheive that i suggest to use fiddler scripts. Here example of scripts in pseudocode
For
BeforeRequest:For
AfterResponse: