Example #1
0
        static void Main(string[] args)
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(CalculatorService), new Uri(baseAddress));
            Dictionary<string, string> namespaceToPrefixMapping = new Dictionary<string, string>
            {
                { "http://www.w3.org/2003/05/soap-envelope", "SOAP12-ENV" },
                { "http://www.w3.org/2005/08/addressing", "SOAP12-ADDR" },
            };
            Binding binding = ReplacePrefixMessageEncodingBindingElement.ReplaceEncodingBindingElement(
                new WSHttpBinding(SecurityMode.None),
                namespaceToPrefixMapping);
            host.AddServiceEndpoint(typeof(ICalculator), binding, "");
            host.Open();

            Binding clientBinding = LoggingMessageEncodingBindingElement.ReplaceEncodingBindingElement(
                new WSHttpBinding(SecurityMode.None));
            ChannelFactory<ICalculator> factory = new ChannelFactory<ICalculator>(clientBinding, new EndpointAddress(baseAddress));
            ICalculator proxy = factory.CreateChannel();

            Console.WriteLine(proxy.Add(234, 456));

            ((IClientChannel)proxy).Close();
            factory.Close();
            host.Close();
        }
Example #2
0
        static void Main(string[] args)
        {
            ChannelFactory<IService> channelFactory = null;
            try
            {
                channelFactory = new ChannelFactory<IService>("Endpoint1");
                ThreadPool.QueueUserWorkItem((o) =>
                    {
                        for (int i = 1; i <= 1000; i++)
                        {
                            Console.WriteLine("{0}: invocate service! thread 1", i);
                            Console.WriteLine(channelFactory.CreateChannel().DoReturn());
                            //Thread.Sleep(1000);
                        }
                    });

                ThreadPool.QueueUserWorkItem((o) =>
                {
                    for (int i = 1; i <= 1000; i++)
                    {
                        Console.WriteLine("{0}: invocate service! thread 2", i);
                        Console.WriteLine(channelFactory.CreateChannel().DoReturn());
                        //Thread.Sleep(1000);
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                channelFactory.Close();
            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                ChannelFactory<IMyMath> factory = new ChannelFactory<IMyMath>(
                    new WSHttpBinding(),
                    new EndpointAddress("http://localhost/MyMath/Ep1")
                    );
                IMyMath channel = factory.CreateChannel();
                int a;
                string c;
                int b;
                a = Convert.ToInt32(Console.ReadLine());
                c = Console.ReadLine();
                b = Convert.ToInt32(Console.ReadLine());
                Console.ReadLine();

                int result = channel.Add(a, c, b);
                if(result == -2)
                {
                    Console.WriteLine("На нуль ділити не можна ****!!!");
                }
                Console.WriteLine("result: {0}", result);
                Console.WriteLine("Для завершения нажмите <ENTER>\n");
                Console.ReadLine();
                factory.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #4
0
        private void StartDownload()
        {
            new Thread(delegate()
            {
                bool retry = false;
                int count = 0;

                do {
                    retry = false;
                    try {
                        NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                        EndpointAddress address = new EndpointAddress("net.pipe://localhost/download");
                        using (ChannelFactory<IDownloadManager> factory = new ChannelFactory<IDownloadManager>(binding, address))
                        {
                            IDownloadManager dm = factory.CreateChannel();

                            if (dm != null)
                            {
                                string msg = dm.CopyFile("test file");
                                MessageBox.Show(msg);
                            }

                            factory.Close();
                        }
                    }
                    catch (CommunicationException)
                    {
                        retry = (count++ < 30);
                        Thread.Sleep(1000);
                    }
                } while(retry);

            }).Start();
        }
        internal void Start() 
        {
            //Create a proxy to the event service
            EndpointAddress remoteAddress = new EndpointAddress(Config.Communincation.ServiceURI);
            NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
            IChannelFactory<IEventService> channelFactory = new ChannelFactory<IEventService>(netNamedPipeBinding, remoteAddress);
            IEventService eventService = channelFactory.CreateChannel(remoteAddress);
            
            //Signal ready and wait for other threads to join.
            _syncStartBarrier.SignalAndWait();

            EventSource eventSource = new EventSource() { ID = Guid.NewGuid(), Name = string.Format("Publisher:{0}", _Id) };
            Console.WriteLine("{0} Running...", eventSource);

            Event @event = new Event() { Source = eventSource, Info = String.Format("EVENT PUBLISHED AT[{0}]", DateTime.Now.ToLongTimeString()), RecordedAt = DateTime.Now };
            Byte[] bytes = ProtoBufSerializer.Serialize<Event>(@event);

            //Start publishing events
            for (Int64 i = 0; i < _iterations; i++)
            {
                eventService.Handle(bytes);
            }

            channelFactory.Close();
        }
Example #6
0
 public void test_DoctorService_As_Service()
 {
     var channelFactory = new ChannelFactory<IDoctorService>("");
     var proxy = channelFactory.CreateChannel();
     (proxy as ICommunicationObject).Open();
     channelFactory.Close();
 }
Example #7
0
        static void Main(string[] args)
        {
            Console.Write("Enter the name of the user you want to connect with: ");
            string serviceUserName = Console.ReadLine();

            Uri serviceUri = new Uri(String.Format("sb://{0}/services/{1}/EchoService/", ServiceBusEnvironment.DefaultRelayHostName, serviceUserName));

            EndpointAddress address = new EndpointAddress(serviceUri);

            ChannelFactory<IEchoChannel> channelFactory = new ChannelFactory<IEchoChannel>("RelayEndpoint", address);
            IEchoChannel channel = channelFactory.CreateChannel();
            channel.Open();

            Console.WriteLine("Enter text to echo (or [Enter] to exit):");
            string input = Console.ReadLine();
            while (!String.IsNullOrEmpty(input))
            {
                try
                {
                    Console.WriteLine("Server echoed: {0}", channel.Echo(input));
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
                input = Console.ReadLine();
            }

            channel.Close();
            channelFactory.Close();
        }
Example #8
0
        static void Run()
        {
            MsmqIntegrationBinding binding = new MsmqIntegrationBinding();
            binding.Security.Mode = MsmqIntegrationSecurityMode.None;
            EndpointAddress address = new EndpointAddress("msmq.formatname:DIRECT=OS:" + Constants.QUEUE_PATH);

            ChannelFactory<ClassLib.IOrderProcessor> channelFactory = new ChannelFactory<ClassLib.IOrderProcessor>(binding, address);

            try
            {
                ClassLib.IOrderProcessor channel = channelFactory.CreateChannel();

                MyOrder order = new MyOrder();
                order.ID = DateTime.Now.Ticks.ToString();
                order.Name = "Order_" + order.ID;

                MsmqMessage<MyOrder> ordermsg = new MsmqMessage<MyOrder>(order);
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    channel.SubmitPurchaseOrderInMessage(ordermsg);
                    scope.Complete();
                }

                Console.WriteLine("Order has been submitted:{0}", ordermsg);
            }
            finally
            {
                channelFactory.Close();
            }
        }
Example #9
0
 public CommandResult Execute(Command command)
 {
     try
     {
         using (ChannelFactory<IIncinerateService> clientFactory = new ChannelFactory<IIncinerateService>())
         {
             NamedPipeTransportBindingElement transport = new NamedPipeTransportBindingElement();
             CustomBinding binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), transport);
             clientFactory.Endpoint.Binding = binding;
             clientFactory.Endpoint.Address = new EndpointAddress("net.pipe://IncinerateService/incinerate");
             IIncinerateService incinerateProxy = clientFactory.CreateChannel();
             CommandResult result = command.Execute(incinerateProxy);
             clientFactory.Close();
             return result;
         }
     }
     catch (FormatException ex)
     {
         Console.WriteLine("Illegal agruments");
     }
     catch (CommunicationObjectFaultedException ex)
     {
         throw new ServiceException("Service is not working", ex);
     }
     catch (EndpointNotFoundException ex)
     {
         throw new ServiceException("Service is not running", ex);
     }
     catch (CommunicationException ex)
     {
         throw new ServiceException("Can not connect to service", ex);
     }
     return null;
 }
Example #10
0
        static void Main(string[] args)
        {
            Uri uri = new Uri("serial://localhost/com1");
            Console.WriteLine("Creating factory...");

            SerialTransportBinding binding = new SerialTransportBinding("COM1");

            ChannelFactory<ISerialTrasportDemo> factory =
              new ChannelFactory<ISerialTrasportDemo>(binding);

            ISerialTrasportDemo channel =
              factory.CreateChannel(new EndpointAddress(uri));

            Console.Write("Enter Text or x to quit: ");
            string message;
            while ((message = Console.ReadLine()) != "x")
            {
              string result = channel.Reflect(message);

              Console.WriteLine(
                "\nReceived for ProcessReflectRequest: " + result + "\n");
              Console.Write("Enter Text or x to quit: ");
            }

            factory.Close();
        }
        internal static void Main(string[] args)
        {
            Thread.Sleep(2000);

            var binding = ReadOnly.GetBinding();
            var endpoint = new EndpointAddress(string.Concat(ReadOnly.GetProtocol(), "localhost:8080/people"));
            var factory = new ChannelFactory<IPersonService>(binding, endpoint);
            var service = factory.CreateChannel();
            var message = default(Message);

            try {
                message = service.GetPeople();

                foreach (var person in Parse(message)) {
                    Console.WriteLine(person);
                }

                ((ICommunicationObject)service).Close();
            } catch (Exception ex) {
                Trace.WriteLine(ex.Message);
                ((ICommunicationObject)service).Abort();
            } finally {
                factory.Close();
            }

            Console.ReadKey();
        }
Example #12
0
        static void Main(string[] args)
        {
            EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/calculatorservice");
            using (ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>(new SimpleDatagramBinding(), address))
            {
                //创建第一个服务代理
                ICalculator proxy = channelFactory.CreateChannel();
                proxy.Add(1, 2);
                Console.WriteLine("Done");
                proxy.Add(1, 2);
                Console.WriteLine("Done");
                (proxy as ICommunicationObject).Close();

                //创建第二个服务代理
                proxy = channelFactory.CreateChannel();
                proxy.Add(1, 2);
                Console.WriteLine("Done");
                proxy.Add(1, 2);
                Console.WriteLine("Done");
                (proxy as ICommunicationObject).Close();

                channelFactory.Close();
            }
            Console.Read();
        }
        public static void Run(int numberOfMessage)
        {
            try
            {
                int Iteration = numberOfMessage;

                string address = "net.msmq://localhost/private/ReceiveTx";
                NetMsmqBinding binding = new NetMsmqBinding(NetMsmqSecurityMode.None)
                {
                    ExactlyOnce = true,
                    Durable = true
                };

                ChannelFactory<IPurchaseOrderService> channelFactory = new ChannelFactory<IPurchaseOrderService>(binding, address);
                IPurchaseOrderService channel = channelFactory.CreateChannel();

                for (int i = 0; i < Iteration; i++)
                {
                    PurchaseOrder po = new PurchaseOrder()
                    {
                        PONumber = Guid.NewGuid().ToString(),
                        CustomerId = string.Format("CustomerId: {0}", i)
                    };

                    Console.WriteLine("Submitting an PO ...");
                    channel.SubmitPurchaseOrder(po);
                }

                channelFactory.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public void OnShare(object sender, EventArgs e)
        {
            bool putFileNameInUri = this.checkBoxPutFileNameInUrl.Checked;
            int hoursToShare = int.Parse(this.dropDownHoursToShare.SelectedValue);

            var listItem = GetListItem();
            if (listItem == null) return;
            try
            {
                var binding = new WebHttpBinding();
                var endpoint = new EndpointAddress(GetServiceUrl());
                var channelFactory = new ChannelFactory<Services.IAzureSharer>(binding, endpoint);
                channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());
                var client = channelFactory.CreateChannel();
                var fileModel = new Services.FileModel()
                                    {
                                        FileName = HttpUtility.UrlEncode(listItem.File.Name),
                                        FileContent = listItem.File.OpenBinary(),
                                        HoursToShare = hoursToShare,
                                        PutFileNameInUrl = putFileNameInUri
                                    };
                var blobToken = client.ShareFile(fileModel);

                ((IClientChannel)client).Close();
                channelFactory.Close();

                this.textBoxGeneratedLink.Text = String.Format("{0}/{1}",GetServiceUrl(),blobToken);
            }
            catch (Exception ex)
            {
                SPUtility.TransferToErrorPage(String.Format("Tried to upload {0} with {1} bytes, got error {2}", listItem.File.Name, listItem.File.OpenBinary().Length, ex.Message));
            }
        }
        public Task Run(string serviceBusHostName, string token)
        {
            Console.Write("Enter your nick:");
            var chatNickname = Console.ReadLine();
            Console.Write("Enter room name:");
            var session = Console.ReadLine();

            var serviceAddress = new UriBuilder("sb", serviceBusHostName, -1, "/chat/" + session).ToString();
            var netEventRelayBinding = new NetEventRelayBinding();
            var tokenBehavior = new TransportClientEndpointBehavior(TokenProvider.CreateSharedAccessSignatureTokenProvider(token));

            using (var host = new ServiceHost(this))
            {
                host.AddServiceEndpoint(typeof(IChat), netEventRelayBinding, serviceAddress)
                    .EndpointBehaviors.Add(tokenBehavior);
                host.Open();

                using (var channelFactory = new ChannelFactory<IChat>(netEventRelayBinding, serviceAddress))
                {
                    channelFactory.Endpoint.Behaviors.Add(tokenBehavior);
                    var channel = channelFactory.CreateChannel();

                    this.RunChat(channel, chatNickname);

                    channelFactory.Close();
                }
                host.Close();
            }
            return Task.FromResult(true);
        }
 public void test_account_manager_as_service()
 {
     ChannelFactory<IAccountService> channelFactory = new ChannelFactory<IAccountService>("");
     IAccountService proxy = channelFactory.CreateChannel();
     (proxy as ICommunicationObject).Open();
     channelFactory.Close();
 }
Example #17
0
        private void MonitorForm_Load(object sender, EventArgs e)
        {
            string header = string.Format("{0, -13}{1, -22}{2}", "Client", "Time", "Event");
            this.listBoxExecutionProgress.Items.Add(header);
            _syncContext = SynchronizationContext.Current;
            _channelFactory = new ChannelFactory<ICalculator>("calculatorservice");

            EventMonitor.MonitoringNotificationSended += ReceiveMonitoringNotification;
            this.Disposed += delegate
            {
                EventMonitor.MonitoringNotificationSended -= ReceiveMonitoringNotification;
                _channelFactory.Close();
            };

            for (int i = 1; i <= 5; i++)
            {
                ThreadPool.QueueUserWorkItem(state =>
                {
                    int clientId = Interlocked.Increment(ref clientIdIndex);
                    ICalculator proxy = _channelFactory.CreateChannel();
                    using (proxy as IDisposable)
                    {
                        EventMonitor.Send(clientId, EventType.StartCall);
                        using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
                        {
                            MessageHeader<int> messageHeader = new MessageHeader<int>(clientId);
                            OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.CientIdHeaderLocalName, EventMonitor.CientIdHeaderNamespace));
                            proxy.Add(1, 2);
                        }
                        EventMonitor.Send(clientId, EventType.EndCall);
                    }
                }, null);
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            ChannelFactory<ISampleContract> channelFactory = new ChannelFactory<ISampleContract>("sampleProxy");
            ISampleContract proxy = channelFactory.CreateChannel();

            int[] windSpeeds = new int[] { 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 };

            Console.WriteLine("Reporting the next 10 wind speeds.");
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(windSpeeds[i] + " kph");
                try
                {
                    proxy.ReportWindSpeed(windSpeeds[i]);
                }
                catch (CommunicationException)
                {
                    Console.WriteLine("Server dropped a message.");
                }
            }

            Console.WriteLine("Press ENTER to shut down client");
            Console.ReadLine();

            ((IChannel)proxy).Close();
            channelFactory.Close();
        }
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var order = new CourseOrder
                {
                    Course = new Course()
                    {
                        Title = comboBoxCourses.Text
                    },
                    Customer = new Customer
                    {
                        Company = textCompany.Text,
                        Contact = textContact.Text
                    }
                };

                var factory = new ChannelFactory<ICourseOrderService>("queueEndpoint");
                ICourseOrderService proxy = factory.CreateChannel();
                proxy.AddCourseOrder(order);
                factory.Close();

                MessageBox.Show("Course Order submitted", "Course Order",
                      MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (MessageQueueException ex)
            {
                MessageBox.Show(ex.Message, "Course Order Error",
                      MessageBoxButton.OK, MessageBoxImage.Error);
            }

        }
Example #20
0
 public List<User> GetUsers(bool onlineOnly)
 {
     if (onlineOnly)
     {
         var cf = new ChannelFactory<IContactsStatusService>("contactsservice");
         var channel = cf.CreateChannel();
         var users = channel.GetOnlineContacts();
         if (cf.State == CommunicationState.Opened)
         {
             cf.Close();
         }
         return users;
     }
     else
     {
         var cf = new ChannelFactory<IDataService>("dataservice");
         var channel = cf.CreateChannel();
         var users = channel.GetUsers(appKey);
         if (cf.State == CommunicationState.Opened)
         {
             cf.Close();
         }
         return users;
     }
 }
        public async Task Run(string httpAddress, string sendToken)
        {
            var channelFactory =
                new ChannelFactory<IEchoChannel>("ServiceBusEndpoint", new EndpointAddress(httpAddress));
            channelFactory.Endpoint.Behaviors.Add(
                new TransportClientEndpointBehavior(TokenProvider.CreateSharedAccessSignatureTokenProvider(sendToken)));

            using (IEchoChannel channel = channelFactory.CreateChannel())
            {
                Console.WriteLine("Enter text to echo (or [Enter] to exit):");
                string input = Console.ReadLine();
                while (input != string.Empty)
                {
                    try
                    {
                        Console.WriteLine("Server echoed: {0}", channel.Echo(input));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e.Message);
                    }
                    input = Console.ReadLine();
                }
                channel.Close();
            }
            channelFactory.Close();
        }
Example #22
0
        public void test_hiring_manager_as_service()
        {
            var factory = new ChannelFactory<IHiringService>("");
            var proxy = factory.CreateChannel();

            (proxy as ICommunicationObject).Open();
            factory.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ChannelFactory<CustomWorkflowLibrary.IWorkflow1> factory = new ChannelFactory<CustomWorkflowLibrary.IWorkflow1>("WSHttpContextBinding_IWorkflow1");
            CustomWorkflowLibrary.IWorkflow1 channel = factory.CreateChannel();
            int res = channel.CalcData(int.Parse(textBox1.Text));
            factory.Close();

            MessageBox.Show(res.ToString());
        }
Example #24
0
        private void btnCallSerivceMethod_Click(object sender, EventArgs e)
        {
            //
            // クライアントの構築.
            //
            // WCFにて、クライアント側は以下の処理を行う必要がある。
            //
            //   1.エンドポイントアドレスの構築
            //   2.ChannelFactoryの構築
            //   3.サービスの呼び出し
            //
            // 通常、WCFでは直接ChannelFactoryなどを構築せず
            // 「サービス参照の追加」を利用して、クライアントプロキシを自動生成する。
            //
            // さらに、エンドポイントアドレスの設定などは、アプリケーション構成ファイルに
            // 設定するのが通例となる。
            //
            // エンドポイントアドレスの構築.
            EndpointAddress endpointAddr = new EndpointAddress(ENDPOINT_ADDRESS);

            string result = String.Empty;
            try
            {
                //
                // チャネルを構築しサービス呼び出しを行う.
                //
                using (ChannelFactory<IMyService> channel = new ChannelFactory<IMyService>(new BasicHttpBinding()))
                {
                    //
                    // サービスへのプロキシを取得.
                    //
                    IMyService service = channel.CreateChannel(endpointAddr);

                    //
                    // サービスメソッドの呼び出し.
                    //
                    result = service.SayHello("WCF Study");

                    //
                    // チャネルを閉じる.
                    //
                    channel.Close();
                }
            }
            catch (CommunicationException ex)
            {
                //
                // エラーが発生.
                //
                // WCFでは、サービスとクライアント間の通信中にエラーが発生した場合
                // CommunicationExceptionがスローされる。
                //
                MessageBox.Show(ex.Message);
            }

            lblResult.Text = result;
        }
        public void test_rental_manager_as_service()
        {
            var channelFactory = new ChannelFactory<IRentalService>("");
            var proxy = channelFactory.CreateChannel();

            (proxy as ICommunicationObject).Open();

            channelFactory.Close();
        }
        public void TestActivityManager()
        {
            ChannelFactory<IActivitiesService> channelFactory =
                new ChannelFactory<IActivitiesService>("");

            IActivitiesService proxy = channelFactory.CreateChannel();
            (proxy as ICommunicationObject).Open();
            ActivityDetailsDataContract result =  proxy.GetAllActivities("GANGTOK", "HIGHFLY", null);
            channelFactory.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ChannelFactory<SampleServer.ICalcService> factory = new ChannelFactory<SampleServer.ICalcService>("CustomBinding_ICalcService");
            factory.Open();
            SampleServer.ICalcService channel = factory.CreateChannel();
            string result = channel.SetValue(int.Parse(textBox1.Text));
            factory.Close();

            MessageBox.Show(result);
        }
        /// <summary>
        /// Choose any example you like to run.
        /// </summary>
        /// <param name="arg"></param>
        static void Main(string[] arg)
        {
            // Just use any usable endpoint in the config file.
            _factory = new ChannelFactory<ICiviCrmApi>("*");
   
            Example9();

            _factory.Close();
            Console.WriteLine("Press enter.");
            Console.ReadLine();
        }
Example #29
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Starting test service...");

            var binding = new BasicHttpBinding ();
            //var binding = new NetTcpBinding();

            var baseAddress = new Uri ("http://localhost:8090");

            //var endpointAddress = new Uri("net.tcp://localhost:1111");
            var endpointAddress = new Uri("http://localhost:8090");

            // ---- ServiceHost & adding endpoints...
            var host = new ServiceHost (typeof (TestService), baseAddress);

            host.AddServiceEndpoint (typeof (ITestService), binding, endpointAddress);

            // Add the MEX
            var smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
            if (smb == null)
            {
                smb = new ServiceMetadataBehavior();
                host.Description.Behaviors.Add(smb);
            }

            smb.HttpGetEnabled = true;

            host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
            host.Open ();

            Console.WriteLine("Testing the connection using {0}...", binding.GetType ().Name);

            var sw = new Stopwatch();
            sw.Start();
            var channelFactory = new ChannelFactory<ITestService>(binding, new EndpointAddress(endpointAddress));

            var channel = channelFactory.CreateChannel();

            for(int i = 0; i < 5; i++)
            {
                Console.WriteLine("Connecting...");
                Console.WriteLine (channel.GetTime());
            }

            channelFactory.Close ();

            sw.Stop();
            Console.WriteLine("Took {0}ms", sw.ElapsedMilliseconds);

            Console.WriteLine ("Type [Enter] to stop...");
            Console.ReadLine();

            host.Close ();
        }
 private void button1_Click(object sender, EventArgs e)
 {
     ChannelFactory<CustomWorkflowLibrary.IWorkflow1> factory = new ChannelFactory<CustomWorkflowLibrary.IWorkflow1>("WSHttpContextBinding_IWorkflow1");
     CustomWorkflowLibrary.IWorkflow1 channel = factory.CreateChannel();
     int res = channel.CalcCost(int.Parse(textBox1.Text),
         int.Parse(textBox2.Text),
         int.Parse(textBox3.Text),
         int.Parse(textBox4.Text));
     textBox5.Text = res.ToString();
     factory.Close();
 }
Example #31
0
 public void Close(TimeSpan timeout)
 {
     _channelFactory.Close(timeout);
 }