You have 2 options:
- use extensibility WCF. this will usually be more work and you will need to consider the various wcf situations.
- use an out-of-band solution like wirehark
Iβm not sure why you prefer the first - I recommend trying wirehark, Iβm sure that it can also be automated. In any case, if you want to do this inside wcf, you must implement a special message encoder to size the size of the bytes that go to the wire. it must be a common encoder that any other encoder wraps in. here is an example for a common encoder. note that the encoder approach only considers the size of the message, but does not crop it at the top (for example, HTTP headers). That is why I think wirehark is better for your business.
source share