public void BeforeSendReply(ref Message reply, object correlationState)
        {
            MessageBuffer messageBuffer = reply.CreateBufferedCopy(Int32.MaxValue);

            // Create string builders
            StringBuilder source = GetMessageBufferAsStringBuilder(messageBuffer);

            // In case of an error, do not modify the message
            if (source.ToString().StartsWith("<s:Fault"))
            {
                reply = messageBuffer.CreateMessage();
                return;
            }

            StringBuilder target = new StringBuilder();

            // Read source xml
            StringReader sr = new StringReader(source.ToString());
            XmlTextReader reader = new XmlTextReader(sr);

            // Write target xml
            StringWriter sw = new StringWriter(target);
            XmlManglingWriter writer = new XmlManglingWriter(sw);
            writer.WriteNode(reader, true);

            reader.Close();
            writer.Flush();
            writer.Close();

            // Set target message
            reply = GetStringBuilderAsNewMessage(reply, target);

            // Log message
            //MessageLogger.LogReply(ref reply, log);
        }
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            MessageBuffer messageBuffer = reply.CreateBufferedCopy(Int32.MaxValue);

            // Create string builders
            StringBuilder source = GetMessageBufferAsStringBuilder(messageBuffer);

            // In case of an error, do not modify the message
            if (source.ToString().StartsWith("<s:Fault"))
            {
                reply = messageBuffer.CreateMessage();
                return;
            }

            StringBuilder target = new StringBuilder();

            // Read source xml
            StringReader  sr     = new StringReader(source.ToString());
            XmlTextReader reader = new XmlTextReader(sr);

            // Write target xml
            StringWriter      sw     = new StringWriter(target);
            XmlManglingWriter writer = new XmlManglingWriter(sw);

            writer.WriteNode(reader, true);

            reader.Close();
            writer.Flush();
            writer.Close();

            // Set target message
            reply = GetStringBuilderAsNewMessage(reply, target);

            // Log message
            //MessageLogger.LogReply(ref reply, log);
        }