1

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):

  1. send request, body<productId>1</productId>
  2. get real response, body <productprice>1</productprice>
  3. 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 pattern body contains <productId>1</productId>should be responded from our local storage )
  4. send request, body <productId>1</productId>
  5. load response from local storage and return HTTP/1.1 200 OK <productprice>1</productprice>
  6. send request, body <productId>2</productId>
  7. get real response, body <productprice>5</productprice>
  8. 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>"]
  9. ...

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.

Maxim Kitsenko
  • 2,042
  • 1
  • 20
  • 43

1 Answers1

0

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:

var body = session.requestBodyBytes;
var id = GetIdFromBody(body);// code for getting id from request body
session.Reply = id;

For AfterResponse:

var body = session.GetRequestBodyAsString();
var id = GetIdFromRespBody(body);// code for getting id from response body
session.SaveResponse(id);
Maxim Kitsenko
  • 2,042
  • 1
  • 20
  • 43
  • Can you provide the actual scripts please? – f0rt Aug 14 '18 at 14:45
  • I had deleted these scripts since i don't need them anymore. But the most important part of such scripts ( is provided in my response) - is that you can get the body of request/response with help of functions: GetRequestBodyAsString, requestBodyBytes @f0rt – Maxim Kitsenko Aug 17 '18 at 09:03