/// <summary> /// Processes the SOAP Messages and decompresses them if necessary /// </summary> /// <param name="envelope">The <see cref="SoapEnvelope"/> to process.</param> public override void ProcessMessage(SoapEnvelope envelope) { if (envelope.Header == null) { return; } //check if the ZipFilter has been applied. XmlNodeList elemList = envelope.Header.GetElementsByTagName(Constants.WSCFCompressionElement); if (elemList.Count == 0) { return; } //The header contains the element, let's check if the body is compressed if (elemList[0].Attributes[Constants.WSCFAttribute].Value.Equals("0")) { return; } //make sure we decompress using the same method we used for compression. WSCFCompression.CompressionProvider = (CompressionType)Convert.ToInt32((string)elemList[0].Attributes[Constants.WSCFTypeAttribute].Value); //remove the element from the envelope, it's no longer necessary. envelope.Header.RemoveChild(elemList[0]); //decompress the envelope attachments MemoryStream outStream = WSCFCompression.DeCompressToStream(envelope.Context.Attachments[0].Stream); //replace the body element. XmlElement body = envelope.CreateBody(); body.InnerXml = System.Text.Encoding.UTF8.GetString(outStream.ToArray()); GC.Collect(); }