//
        // TODO: at some point it may be necessary to pass in the current version as a parameter if the transforms become
        // more complicated.
        //

        /// <summary>
        /// Constructor.  We read all the XML sent from the server, do our version manipulation, then write the new XML
        /// into our inner responseStream object.
        /// </summary>
        /// <param name="responseStream">This object should be the responseStream from a WebResponse object.</param>
        public UddiResponseStream(Stream responseStream)
        {
            try
            {
                //
                // Get the XML the server sent to us.
                //
                StreamReader reader      = new StreamReader(responseStream);
                string       responseXml = reader.ReadToEnd();
                reader.Close();

                //
                // TODO: Consider making this class more generic, ie. have a IUddiResponseHandler interface:
                //	IUddiResponseHandler
                //		string HandleResponse( string xml );
                //

                //
                // Translate the incoming XML into the current version.
                //
                string transformedXml = UddiVersionSupport.Translate(responseXml, UddiVersionSupport.CurrentVersion);

                //
                // Write this transformed XML into the 'real' stream.
                //
                StreamUtility.WriteStringToStream(this, transformedXml);
            }
            finally
            {
                this.Position = 0;
            }
        }
        /// <summary>
        /// Before we actually close the request stream, we want to manipulate the XML.
        /// </summary>
        public override void Close()
        {
            try
            {
                //
                // Rewind ourselves.
                //
                this.Position = 0;

                //
                // Read the XML that was written; this is the XML request that will be sent to the Uddi server.
                //
                StreamReader reader     = new StreamReader(this);
                string       requestXml = reader.ReadToEnd();

                //
                // TODO: Consider making this class more generic, ie. have a IUddiRequestHandler interface:
                //	IUddiResponseHandler
                //		string HandleRequest( string xml );
                //

                //
                // Transform the content to a correct version on the server if we are not using the current version.
                //
                string transformedXml = requestXml;
                if (uddiVersion != UddiVersionSupport.CurrentVersion)
                {
                    transformedXml = UddiVersionSupport.Translate(requestXml, uddiVersion);
                }

                //
                // Write the transformed data to the 'real' stream.
                //
                StreamUtility.WriteStringToStream(innerStream, transformedXml);
            }
            finally
            {
                //
                // Make sure we clean up properly.
                //
                innerStream.Close();
                base.Close();
            }
        }