This week I found myself wanting to look at the raw XML data sent between a client and a service. Of course the WCF tool SvcTraceViewer generally makes more sense to use for tracing, but sometimes it's necessary to look at the actual data on the wire. In such case a tcp trace tool can be used and placed in-between the caller and the service. In the end this was really easy to setup but in order to save someone else the hour or so to figure it out here's how it works:
For tracing I used Simon Fell's tcpTrace available at http://www.pocketsoap.com/tcptrace/.
First start tcpTrace. It needs to sit in the middle of the call so have it listen to the port the server exposes and forward to different port. Then configure the server to listen to the port tcpTrace forwards to using the listenUri configuration setting. The client doesn't have to be changed since all it does is call tcpTrace, which then forwards to the service. The config used looks like this:
Server config:
<
service name="Service.Calculator">
<endpoint address="http://localhost:8001/CalculatorService"
listenUri="http://localhost:8002/CalculateService"
binding="basicHttpBinding"
contract="Service.ICalculator"
/>
</service>
Client config:
<
client>
<endpoint address="http://localhost:8001/CalculatorService"
binding="basicHttpBinding"
contract="ICalculator"
/>
</client>