Tuesday, 22 October 2013

How to "fiddle" SOAP messages and WCF endpoints.

Today I needed a nice easy way to look at the raw SOAP data being sent over the wire between the WCF test client and a custom WCF endpoint. For a quick peek, I figured I’d turn to fiddler for this job, but found very quickly that fiddler didn’t capture the traffic – most likely because fiddler drops itself in as a proxy that your browser uses, but clearly the WCF test client doesn’t.

The fix though is easy.

In WCF tester, add your reference to your service, say http://localhost:12345/myservice.svc. Then, right click on the “Config File” node in WCF tester and select to edit with SvcConfigEditor. Find your endpoint under client -> endpoint, and then change http://localhost:12345/myservice.svc to http://localhost.fiddler:12345/myservice.svc and hey presto, the traffic gets pushed through fiddler.

You might wonder why I didn’t just add the service reference as http://localhost.fiddler:12345/myservice.svc - well, when I did that, any method invocations didn’t seem to trace in fiddler. May have been  user error on my part, but the above worked for me and I could diagnose the raw SOAP messages.