Exemplo n.º 1
0
 /// <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();
 }
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();
        }
Exemplo n.º 3
0
        /// <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();
        }
		private void AddSubscriber(string ID, Uri replytoAddress, string Name)
		{
			SoapSender ssend = new SoapSender(replytoAddress);
			SoapEnvelope response = new SoapEnvelope();
			response.CreateBody();
			response.Body.InnerXml = String.Format("<x:AddSubscriber xmlns:x='urn:ArticlePublisherApp:Publisher' ><notify>Name: {0} ID: {1}</notify></x:AddSubscriber>", Name, ID);
			Action act = new Action("response");
			response.Context.Addressing.Action = act;
			ssend.Send(response);
			_subscribers.Add ( ID, new Subscriber(Name,replytoAddress, ID)  );
			OnNewSubscriberEvent(Name, ID, replytoAddress);

		}
Exemplo n.º 5
0
        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);
        }
		private void RemoveSubscriber(string ID, Uri replytoAddress)
		{
			if (_subscribers.Contains(ID) )
			{
				_subscribers.Remove(ID);
				SoapSender ssend = new SoapSender(replytoAddress);
				SoapEnvelope response = new SoapEnvelope();
				response.CreateBody();
				response.Body.InnerXml = String.Format("<x:RemoveSubscriber xmlns:x='urn:ArticlePublisherApp:Publisher' ><notify>ID: {0} Removed</notify></x:RemoveSubscriber>", ID);
				Action act = new Action("response");
				response.Context.Addressing.Action = act;
				ssend.Send(response);
				OnRemoveSubscriberEvent(ID);
			}
		}
		private void fsw_Created(object sender, System.IO.FileSystemEventArgs e)
		{
			Uri uriThis =  new Uri (Literals.LocalhostTCP + "9090/Publisher" );
			// Send each subscriber a message
			foreach(object o in _subscribers)
			{
				DictionaryEntry de = (DictionaryEntry)o;
				
				Subscriber s = (Subscriber)_subscribers[de.Key];
				SoapEnvelope responseMsg = new SoapEnvelope ();

				FileStream fs = new FileStream(e.FullPath ,FileMode.Open, FileAccess.Read , FileShare.ReadWrite );
				StreamReader sr = new StreamReader(fs);
				string strContents = sr.ReadToEnd() ;
				sr.Close();
				fs.Close();

				// Set the From Addressing value
				responseMsg.Context.Addressing.From = new From ( uriThis );
				responseMsg.Context.Addressing.Action  = new Action( "notify");
				responseMsg.CreateBody();
				responseMsg.Body.InnerXml = "<x:ArticlePublished xmlns:x='urn:ArticlePublisherApp:Publisher'><notify><file>" + e.Name +"</file><contents>" + strContents + "</contents></notify></x:ArticlePublished>";

				// Send a Response Message
				SoapSender msgSender = new SoapSender (s.ReplyTo );
				msgSender.Send ( responseMsg );
			}
		}
Exemplo n.º 8
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();
        }