title: C# extending SoapExtension -
body: <p><strong>Background:</strong>
  I'm trying to write a simple SoapExtension class to log inbound/outbound Soap messages from an asmx web service. Following <a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension%28VS.85%29.aspx">this article on msdn</a>, I have been able to get things working. However I'd really like to understand why/how it's working rather than just copy &amp; pasting code.</p>
  
  <p><strong>The question:</strong>
  What I'm stuggling to grasp specifically is the handling of the IO streams in the example. All other articles I've read on the web handle the streams in an identical way... first getting a reference to the original stream, creating an in memory "working" stream, and then swapping the contents as necessary.</p>
  
  <p>First question is, what is meant by "stream chaining" in this context? My understaning of streams is that writing to any stream will automatically write to the 'inner' streams in a pipeline. If that's the case, why is it necessary to manually copy contents from one stream to another?</p>
  
  <p>Second question is, in the examples Copy method they're creating a StreamReader and StreamWriter each time, without disposing them - is this not putting extra pressure on the GC? Doesn't seem like something you'd want on a high traffic web service... I tried wrapping both in using statements, but disposing the reader/writer also closed the stream which led to more serious errors. .NET 4 has new Stream.CopyTo(Stream) methods, but what would be a better approach for .NET 3.5?</p>