Пример #1
0
        static void Main(string[] args)
        {
            MyBinding binding = new MyBinding();
            IChannelFactory<IRequestChannel> channelFactory = binding.BuildChannelFactory<IRequestChannel>();
            channelFactory.Open();

            IRequestChannel channel = channelFactory.CreateChannel(new EndpointAddress("http://127.0.0.1:8888/messagingviabinding"));
            channel.Open();

            Message requestMessage = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "http://artech.messagingviabinding", "This is a mannualy created reply message for the purpose of testing");
            Message replyMessage = channel.Request(requestMessage);
            Console.WriteLine("Receive a reply message:\n{0}", replyMessage);
            channel.Close();
            channelFactory.Close();
            Console.Read();
        }
Пример #2
0
        static void Main(string[] args)
        {
            MyBinding binding = new MyBinding();
            IChannelListener<IReplyChannel> channelListener = binding.BuildChannelListener<IReplyChannel>(new Uri("http://127.0.0.1:8888/messagingviabinding"));
            channelListener.Open();

            while (true)
            {
                IReplyChannel channel = channelListener.AcceptChannel(TimeSpan.MaxValue);
                channel.Open();
                RequestContext context = channel.ReceiveRequest(TimeSpan.MaxValue);

                Console.WriteLine("Receive a request message:\n{0}", context.RequestMessage);
                Message replyMessage = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "http://artech.messagingviabinding", "This is a mannualy created reply message for the purpose of testing");
                context.Reply(replyMessage);
                channel.Close();
            }
        }