Example #1
0
        protected void doReceive(SoapEnvelope message)
        {
            log.Info( "Request -- " + message.Envelope.InnerXml );

            SoapSender sender = new SoapSender( message.Context.Addressing.ReplyTo.Address.Value );
            SoapEnvelope responseMessage = new SoapEnvelope( );

            responseMessage.Context.Addressing.Action = new Action( "http://weblogs.shockbyte.com.ar/rodolfof/wse/samples/2006/05/SampleServiceRequest#Response" );

            log.Info("Response -- " + responseMessage.Envelope.InnerXml);
            sender.Send( responseMessage );
        }
		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);

		}
Example #3
0
        public void Run(string[] args)
        {
            SoapEnvelope message = new SoapEnvelope( );

            Uri viaUri = null;
            Uri toUri = null;
            Uri replyUri = null;
            if (args.Length >= 1)
            {
                switch (args[0])
                {
                    case "UDP":
                        viaUri = new Uri("soap.udp://127.0.0.1:6000");
                        toUri = new Uri("soap.udp://weblogs.shockbyte.com.ar/rodolfof/wse/samples/2006/05/SampleReceiver");
                        replyUri = new Uri("soap.udp://127.0.0.1:6001");
                        break;
                    case "SMTP":
                        viaUri = new Uri("soap.smtp://[email protected]");
                        toUri = new Uri("soap.smtp://weblogs.shockbyte.com.ar/rodolfof/wse/samples/2006/05/SampleReceiver");
                        replyUri = new Uri("soap.smtp://[email protected]");
                        break;
                    case "SQL":
                        viaUri = new Uri("soap.sql://localhost/sqlexpress");
                        toUri = new Uri("soap.sql://weblogs.shockbyte.com.ar/rodolfof/wse/samples/2006/05/SampleReceiver");
                        replyUri = new Uri("soap.sql://localhost/Client");
                        break;
                    default:
                        Help();
                        return;
                        break;
                }
            }
            else
            {
                Help();
                return;
            }

            message.Context.Addressing.Action = new Action( "http://weblogs.shockbyte.com.ar/rodolfof/wse/samples/2006/05/SampleServiceRequest" );
            message.Context.Addressing.ReplyTo = new ReplyTo( replyUri );

            SoapSender sender = new SoapSender( new EndpointReference( toUri, viaUri ) );

            SoapReceivers.Add( replyUri, typeof( ReplyReceiver ) );

            sender.Send( message );

            Console.WriteLine( "Calling {0}", sender.Destination.Address.Value );
        }
		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 );
			}
		}