2

Here is the setup I currently have:

Client App -----> Intermediary Web API Service (receives calls from clients) ------> 3rd party RESTful service (receives calls from intermediary service)

So if I make calls that originate from the client to the intermediary service or calls that originate from the intermediary service to the 3rd party service I can use Fiddler or Wireshark to inspect the POSTed XML/JSON.

The problem is when I make a call from the client all the way through, and I want to inspect the actual raw HTTP outgoing messages being sent from the intermediary service to the 3rd party service. If I run Fiddler on the server that contains the intermediary service, I do not see the HTTP traffic going outbound from it. I also tried Wireshark and it does not pick up the traffic either. However I know it's occurring because the 3rd party service is sending me errors back.

The intermediary service acts as a facade for the client apps to the 3rd party service and massages the data from the client before making another HTTP client outbound to the 3rd party service. I'm having trouble with the outgoing messages being accepted by the 3rd party service and really need to see the raw HTTP message being omitted by the intermediary service (I'm using a HttpClient.PostAsync to POST the data to the 3rd party service). I already persist it to the database before sending but what I'm pulling out seems to be OK.

So the main question, how do I get that message that my intermediary service is POSTing to the 3rd party service? Is there something with Fiddler, Wireshark or another program that I can use to inspect that HTTP message going outbound from that intermediary service?

atconway
  • 20,624
  • 30
  • 159
  • 229

2 Answers2

2

Configure your "intermediary Web API service" to proxy its traffic through a Fiddler instance running on the same (or a different) computer, and this will work fine.

If your service is written in .NET, you can either configure its proxy manually: http://www.fiddler2.com/fiddler/help/hookup.asp#Q-DOTNET or you can update the machine.config or web.config: http://www.telerik.com/automated-testing-tools/blog/eric-lawrence/13-01-08/capturing-traffic-from-net-services-with-fiddler.aspx so that its traffic goes through the Fiddler instance.

EricLaw
  • 56,563
  • 7
  • 151
  • 196
0

I don't think Fiddler will work as it only intercept the calls made in a browser. Can you make a modification to your intermediary code ?. You can inject a handler for logging the message in the HttpClient that use to make a call to the third party service. The handler would look like this,

public class LogginHandler : DelegatingHandler
{
    public LogginHandler(HttpMessageHandler inner)
        : base(inner)
    {
    }

    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
    {
            using (var fs = new FileStream("c:\\temp\\log.txt", FileMode.Create, FileAccess.Write))
            {
                await request.Content.CopyToAsync(fs);
            }

            return await base.SendAsync(request, cancellationToken);

    }
}

And the code for injecting this handler in an HttpClient instance like this,

HttpClient client = new HttpClient(new LogginHandler(new HttpClientHandler()));
Pablo Cibraro
  • 3,769
  • 3
  • 25
  • 17
  • This is a great suggestion, and I think it will work. Right now I'm in the process of installing VS.NET on the server to run the code directly so that I can spin it up in a browser and capture the traffic from Fiddler. If this works, this would be ideal. – atconway Apr 02 '13 at 15:26
  • 1
    Fiddler works fine for capturing traffic from ANY HTTP/HTTPS client (including non-browser clients). – EricLaw Apr 02 '13 at 17:38
  • @EricLaw - I was reading this post, is the configuration in the answer what is required so Fiddler will pick up all traffic? http://stackoverflow.com/questions/4428680/how-do-i-monitor-all-incoming-http-requests?rq=1 I also tried the Microsoft Network Monitor but I just realized I can't see the payload for the secure HTTPS messages I'm sending. The outging HTTPS payload is what I'm interested in inspecting. – atconway Apr 02 '13 at 18:09