Exemplo n.º 1
0
        /// <summary>
        /// Processes the SOAP Messages and compresses them if necessary
        /// </summary>
        /// <param name="envelope">The <see cref="SoapEnvelope"/> to process.</param>
        public override void ProcessMessage(SoapEnvelope envelope)
        {
            if (!enabled)
            {
                return;
            }
            //add an attribute to specify that the filter has been applied on this envelope.
            XmlElement soapHeader = envelope.CreateHeader();

            if (envelope.Body.InnerText.Length < minFilterSize)
            {
                return;
            }
            else
            {
                soapHeader.AppendChild(CreateCustomHeader(soapHeader, "1"));
            }
            //compress the body element.
            MemoryStream result = new MemoryStream(WSCFCompression.Compress(Encoding.UTF8.GetBytes(envelope.Body.InnerXml)));

            //Attach zipped result to the envelope.
            Microsoft.Web.Services2.Attachments.Attachment attch = new Microsoft.Web.Services2.Attachments.Attachment("APPLICATION/OCTET-STREAM", result);
            envelope.Context.Attachments.Add(attch);

            //remove old body.
            XmlElement newBody = envelope.CreateBody();

            newBody.RemoveAll();
            envelope.SetBodyObject(newBody);
            GC.Collect();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the SOAP Messages and compresses them if necessary
        /// </summary>
        /// <param name="envelope">The <see cref="SoapEnvelope"/> to process.</param>
        public override void ProcessMessage(SoapEnvelope envelope)
        {
            if (!enabled)
            {
                return;
            }
            //add an attribute to specify that the filter has been applied on this envelope.
            XmlElement soapHeader = envelope.CreateHeader();

            if (envelope.Body.InnerText.Length < minFilterSize)
            {
                return;
            }
            else
            {
                soapHeader.AppendChild(CreateCustomHeader(soapHeader, "1" ));
            }
            //compress the body element.
            MemoryStream result = new MemoryStream(WSCFCompression.Compress(Encoding.UTF8.GetBytes(envelope.Body.InnerXml)));

            //Attach zipped result to the envelope.
            Microsoft.Web.Services2.Attachments.Attachment attch = new Microsoft.Web.Services2.Attachments.Attachment("APPLICATION/OCTET-STREAM", result);
            envelope.Context.Attachments.Add(attch);

            //remove old body.
            XmlElement newBody = envelope.CreateBody();
            newBody.RemoveAll();
            envelope.SetBodyObject(newBody);
            GC.Collect();
        }