Exemple #1
0
 void ShowEchoDuplexService()
 {
     EchoDuplexServiceClient service = new EchoDuplexServiceClient(new InstanceContext(this), "DualHttpRelative");
     service.Endpoint.Behaviors.Add(_Log);
     Console.WriteLine("Echo Duplex Service Result : " + service.Echo("Hello"));
     Console.WriteLine("Echo Duplex Service Register : " + service.Register("HelloConsole"));
     Thread.Sleep(10 * 1000);
     Console.WriteLine("Echo Duplex Service Un-Register : " + service.UnRegister("HelloConsole"));
 }
        public MainPage()
        {
            InitializeComponent();

            ShowExceptionInWindow(() =>
                {
                    _EchoRiaService = new EchoRiaContext();
                    ButtonEchoRiaService.Click += (s, e) => ShowExceptionInWindow( () => _EchoRiaService.Echo(TextRequest.Text, a => UpdateResponse(a.Value), null));

                    _EchoWcfService = new EchoWcfServiceClient("BasicRelative");
                    _EchoWcfService.EchoCompleted += (s, e) => UpdateResponse(e.Result);
                    ButtonEchoWcfService.Click += (s, e) => _EchoWcfService.EchoAsync(TextRequest.Text);

                    _EchoDuplexService = new EchoDuplexServiceClient(new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll), new EndpointAddress(_DuplexServicePath));
                    _EchoDuplexService.ReceiveReceived += (s, e) => UpdateResponse(e.value);
                    _EchoDuplexService.EchoCompleted += (s, e) => UpdateResponse(e.Result);
                    _EchoDuplexService.RegisterCompleted += (s, e) => UpdateResponse("Echo Duplex Service Register Status : " + e.Result.ToString());
                    _EchoDuplexService.UnRegisterCompleted += (s, e) => UpdateResponse("Echo Duplex Service Un-Register Status : " + e.Result.ToString());
                    ButtonEchoDuplexService.Click += (s, e) => ShowExceptionInWindow(() => _EchoDuplexService.EchoAsync(TextRequest.Text));
                    ButtonEchoDuplexServiceRegister.Click += (s, e) => ShowExceptionInWindow( () => _EchoDuplexService.RegisterAsync(TextRequest.Text));
                    ButtonEchoDuplexServiceUnRegister.Click += (s, e) => ShowExceptionInWindow( () => _EchoDuplexService.UnRegisterAsync(TextRequest.Text));
                });
        }