/// <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(); }
private static SoapEnvelope CreateEnvelopeForGetExhibitBookmark(string request) { var envelope = new SoapEnvelope(SoapProtocolVersion.Soap12); envelope.Envelope.SetAttribute("xmlns:tem", "http://tempuri.org/"); var header = envelope.CreateHeader(); header.SetAttribute("xmlns:wsa", "http://www.w3.org/2005/08/addressing"); header.InnerXml = "<wsa:To>http://localhost:300/EVE.Site.Services/ExhibitBookmarkService.svc</wsa:To>"; var body = envelope.CreateBody(); body.InnerXml = request; return(envelope); }
/// <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(); }