コード例 #1
0
ファイル: MtClient.cs プロジェクト: linyunfeng/mtapi
        public void Open(int port)
        {
            if (port < 0 || port > 65536)
                throw new ArgumentOutOfRangeException("port", "port value is invalid");

            string urlService = "net.pipe://localhost/" + SERVICE_NAME + "_" + port.ToString();

            lock (mClientLocker)
            {
                if (mProxy != null)
                    return;

                var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                bind.MaxReceivedMessageSize = 2147483647;
                bind.MaxBufferSize = 2147483647;
                // Commented next statement since it is not required
                bind.MaxBufferPoolSize = 2147483647;
                bind.ReaderQuotas.MaxArrayLength = 2147483647;
                bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
                bind.ReaderQuotas.MaxDepth = 2147483647;
                bind.ReaderQuotas.MaxStringContentLength = 2147483647;
                bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;

                mProxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
                mProxy.Faulted += mProxy_Faulted;
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Server Started and Listening.....");

            //Host service or Service Instance
            wcf.ServiceHost _wcfServiceHost = new wcf.ServiceHost(typeof(CalculatorLib.Calculator));
            //Add Endpoint
            System.Type _contract = typeof(CalculatorServiceContractLib.ICalculate);
            //Bidning
            wcf.NetNamedPipeBinding _localMachineBidning = new wcf.NetNamedPipeBinding();
            //Address
            string address = "net.pipe://localhost/onmachinecchannel";

            //wcf.Description.ServiceEndpoint _localMachineCommunicationChannel =
            //    new wcf.Description.ServiceEndpoint(
            //    new wcf.Description.ContractDescription(_contract.FullName),
            //    _localMachineBidning,
            //    new wcf.EndpointAddress(address)
            //    );
            //_wcfServiceHost.AddServiceEndpoint(_localMachineCommunicationChannel);
            _wcfServiceHost.AddServiceEndpoint(_contract, _localMachineBidning, address);

            //LAN Clients
            _wcfServiceHost.AddServiceEndpoint(_contract, new NetTcpBinding(), "net.tcp://localhost:5000/lanep");
            //WAN
            _wcfServiceHost.AddServiceEndpoint(_contract, new BasicHttpBinding(), "http://localhost:8001/wanep");

            _wcfServiceHost.Open();// ServiceHost availability for Client Requests

            Console.ReadKey();
        }
コード例 #3
0
        public void CallbackToSyncContext()
        {
            var path = @"net.pipe://127.0.0.1/" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None) { MaxConnections = 5 };

            using (var server = new ServiceHost(new SyncCallbackService(), new Uri(path)))
            {

                server.AddServiceEndpoint(typeof(ISyncCallbackService), binding, path);

                server.Open();
                using (var syncContext = new StaSynchronizationContext())
                {
                    InstanceContext context = null;
                    DuplexChannelFactory<ISyncCallbackService> channelFactory = null;
                    ISyncCallbackService client = null;
                    syncContext.Send(_ => SynchronizationContext.SetSynchronizationContext(syncContext), null);
                    syncContext.Send(_ => context = new InstanceContext(new SyncCallbackServiceCallback()), null);
                    syncContext.Send(_ => channelFactory = new DuplexChannelFactory<ISyncCallbackService>(context, binding),null);
                    syncContext.Send(_ => client =  channelFactory.CreateChannel(new EndpointAddress(path)),null);
                    using (channelFactory)
                    {
                        var callbackThread = client.Call();
                        Assert.AreEqual(syncContext.ManagedThreadId, callbackThread);
                    }
                }

            }
        }
コード例 #4
0
 /// <summary>
 /// Creates a new client channel if the communication object is null or
 /// is faulted, closed or closing.
 /// </summary>
 private void InitChannel()
 {
     lock (_padlock)
     {
         if (_commObj == null || 
             (_commObj.State != CommunicationState.Opened &&
             _commObj.State != CommunicationState.Opening))
         {
             if (!string.IsNullOrEmpty(_configurationName))
             {
                 _client = new ChannelFactory<IProxyTraceService>(_configurationName).CreateChannel();
             }
             else
             {
                 // Todo - is None really the best choice of security mode?
                 // maybe we should secure the transport by default???
                 NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                 EndpointAddress address = new EndpointAddress(DefaultEndpointAddress);
                 _client = ChannelFactory<IProxyTraceService>.CreateChannel(binding, address);
                 
             }
             _commObj = (ICommunicationObject)_client;
         }
     }
 }
コード例 #5
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            if (this.serviceHost != null)
            {
                this.serviceHost.Close();
            }

            // start ServiceHost 
            var baseUri = new Uri(Prison.changeSessionBaseEndpointAddress);
            Uri serviceUri = baseUri;
            //Debugger.Launch();
            if (this.serviceId != null)
            {
                serviceUri = new Uri(Prison.changeSessionBaseEndpointAddress + "/" + this.serviceId);
            }

            var bind = new NetNamedPipeBinding();
            bind.Security.Mode = NetNamedPipeSecurityMode.Transport;
            bind.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;

            serviceHost = new ServiceHost(typeof(Executor), serviceUri);

            //serviceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = false, HttpsGetEnabled = false });
            //serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
            //serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>().HttpHelpPageUrl = serviceUri;

            serviceHost.AddServiceEndpoint(typeof(IExecutor), bind, string.Empty);

            //this.serviceHost = new ServiceHost(typeof(Executor));

            this.serviceHost.Open();
        }
コード例 #6
0
        /// <summary>
        /// Initializes and hosts all services.
        /// </summary>
        public void Initialize()
        {
            // Host the public web service
            if (_settingWSIsEnabled.Value)
            {
                string address = string.Format("http://localhost:{0}/AlarmWorkflow/AlarmWorkflowService", _settingWSPort.Value);
                Binding binding = new WebHttpBinding()
                {
                    HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.WeakWildcard,
                    MaxReceivedMessageSize = int.MaxValue,
                    ReaderQuotas = XmlDictionaryReaderQuotas.Max,
                };

                HostService(address, binding, typeof(IAlarmWorkflowService), new AlarmWorkflowService(_parent));
            }

            // Host the service used for local-machine communication between service and clients (such as the Windows/Linux UI)
            {
                string address = "net.pipe://localhost/alarmworkflow/service";
                NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport)
                {
                    MaxReceivedMessageSize = int.MaxValue,
                    ReaderQuotas = XmlDictionaryReaderQuotas.Max,
                };

                HostService(address, binding, typeof(IAlarmWorkflowServiceInternal), new AlarmWorkflowServiceInternal(_parent));
            }
        }
コード例 #7
0
        public static ChannelFactory<IVocabularyService> GetChannelFactory()
        {
            var binding = new NetNamedPipeBinding
             {
            MaxBufferPoolSize = 2147483647,
            MaxBufferSize = 2147483647,
            MaxReceivedMessageSize = 2147483647,
            SendTimeout = new TimeSpan(0, 5, 0),
            ReceiveTimeout = new TimeSpan(0, 5, 0),
            ReaderQuotas =
            {
               MaxStringContentLength = 2147483647,
               MaxArrayLength = 2147483647,
               MaxDepth = 2147483647,
               MaxBytesPerRead = 2147483647
            }
             };

             var pipeFactory = new ChannelFactory<IVocabularyService>(binding, new EndpointAddress("net.pipe://localhost/VocabularyServiceEndpoint"));

             foreach (OperationDescription op in pipeFactory.Endpoint.Contract.Operations)
             {
            var dataContractBehavior = op.Behaviors.Find<DataContractSerializerOperationBehavior>();
            if (dataContractBehavior != null)
            {
               dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
            }
             }

             return pipeFactory;
        }
コード例 #8
0
		internal void CreateSession()
		{
			Uri serviceAddress = new Uri("net.pipe://localhost/Multitouch.Service/ApplicationInterface");
			EndpointAddress remoteAddress = new EndpointAddress(serviceAddress);
			NetNamedPipeBinding namedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
			namedPipeBinding.MaxReceivedMessageSize = int.MaxValue;
			namedPipeBinding.MaxBufferSize = int.MaxValue;
			namedPipeBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
			namedPipeBinding.ReceiveTimeout = TimeSpan.MaxValue;

			IApplicationInterfaceCallback dispatcher = new MultitouchServiceContactDispatcher(logic);
			InstanceContext instanceContext = new InstanceContext(dispatcher);
			service = new ApplicationInterfaceClient(instanceContext, namedPipeBinding, remoteAddress);

			try
			{
				service.CreateSession();
				MouseHelper.SingleMouseFallback = false;
			}
			catch (EndpointNotFoundException)
			{
				//throw new MultitouchException("Could not connect to Multitouch service, please start Multitouch input server before running this application.", e);
				Trace.TraceWarning("Could not connect to Multitouch service. Enabling single mouse input.");
				SingleMouseClientAndDispatcher client = new SingleMouseClientAndDispatcher(logic);
				service = client;
				dispatcher = client;
				MouseHelper.SingleMouseFallback = true;
			}
			contactDispatcher = dispatcher;
		}
        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();
        }
コード例 #10
0
ファイル: ServiceTest.cs プロジェクト: iimrankhan/WcfEndToEnd
        public void Integration_test_zip_code_retrieval()
        {
            string address = "net.pipe://localhost/GeoService";
            System.ServiceModel.Channels.Binding binding = new NetNamedPipeBinding();

            ServiceHost host = new ServiceHost(typeof(GeoManager));
            host.AddServiceEndpoint(typeof(IGeoService), binding, address);

            //Set IncludeExceptionDetailInFaults to true in code for WCF
            //This would however require that you self-host the WCF service - won't work in IIS hosting scenarios:
            ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();
            // if not found - add behavior with setting turned on
            if (debug == null)
            {
                host.Description.Behaviors.Add(
                     new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
            }
            else
            {
                // make sure setting is turned ON
                if (!debug.IncludeExceptionDetailInFaults)
                {
                    debug.IncludeExceptionDetailInFaults = true;
                }
            }
            host.Open();

            ChannelFactory<IGeoService> factory = new ChannelFactory<IGeoService>(
                binding, new EndpointAddress(address));
            IGeoService proxy = factory.CreateChannel();
            ZipCodeData data = proxy.GetZipInfo("07035");

            Assert.IsTrue(data.City.ToUpper() == "LINCOLN PARK");
            Assert.IsTrue(data.State == "NJ");
        }
コード例 #11
0
        public void ServerAncClientExceptionsEndpointBehavior()
        {
            var hook = new ExceptionsEndpointBehaviour();
            var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var serv = new ExceptionService();
            using (var host = new ServiceHost(serv, new Uri[] { new Uri(address), }))
            {
                var b = new NetNamedPipeBinding();
                var serverEndpoint = host.AddServiceEndpoint(typeof(IExceptionService), b, address);
                serverEndpoint.Behaviors.Add(hook);

                host.Open();

                var f = new ChannelFactory<IExceptionService>(b);
                f.Endpoint.Behaviors.Add(hook);

                var c = f.CreateChannel(new EndpointAddress(address));

                try
                {
                    c.DoException("message");
                }
                catch (InvalidOperationException ex)
                {
                    StringAssert.AreEqualIgnoringCase("message", ex.Message);
                }
                host.Abort();
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: kirigishi123/try_samples
        private void ReadyRemoteProcess()
        {
            string uri = "net.pipe://localhost/download";

            DownloadManager dm = new DownloadManager();
            dm.CopyFileCallBack = delegate(string file)
            {
                return doCopyFile(file);
            };

            try
            {
                this.host = new ServiceHost(dm);

                NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                host.AddServiceEndpoint(typeof(IDownloadManager), binding, uri);

                host.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.host = null;
            }
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: kirigishi123/try_samples
        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();
        }
コード例 #14
0
 public void CreateChannel()
 {
   Binding binding;
   EndpointAddress endpointAddress;
   bool useAuth = !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
   if (IsLocal(ServerName))
   {
     endpointAddress = new EndpointAddress("net.pipe://localhost/MPExtended/TVAccessService");
     binding = new NetNamedPipeBinding { MaxReceivedMessageSize = 10000000 };
   }
   else
   {
     endpointAddress = new EndpointAddress(string.Format("http://{0}:4322/MPExtended/TVAccessService", ServerName));
     BasicHttpBinding basicBinding = new BasicHttpBinding { MaxReceivedMessageSize = 10000000 };
     if (useAuth)
     {
       basicBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
       basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
     }
     basicBinding.ReaderQuotas.MaxStringContentLength = 5*1024*1024; // 5 MB
     binding = basicBinding;
   }
   binding.OpenTimeout = TimeSpan.FromSeconds(5);
   ChannelFactory<ITVAccessService> factory = new ChannelFactory<ITVAccessService>(binding);
   if (factory.Credentials != null && useAuth)
   {
     factory.Credentials.UserName.UserName = Username;
     factory.Credentials.UserName.Password = Password;
   }
   TvServer = factory.CreateChannel(endpointAddress);
 }
コード例 #15
0
ファイル: StartupTimeTests.cs プロジェクト: OpenSharp/NDceRpc
 public void NamedPipeCallbck()
 {
     var binding = new NetNamedPipeBinding { MaxConnections = 5 };
     var path = "net.pipe://127.0.0.1/testpipename";
     DoHostWithCallback(binding, path);
     DoHostWithCallback(binding, path);
 }
コード例 #16
0
 protected override void OnStart(string[] args)
 {
     productsServiceHost = new ServiceHost(typeof(ProductsServiceImpl));
     NetNamedPipeBinding binding = new NetNamedPipeBinding();
     productsServiceHost.AddServiceEndpoint(typeof(IProductsService), binding, "net.pipe://localhost/ProductsServicePipe");
     productsServiceHost.Open();
 }
コード例 #17
0
ファイル: PerformanceTests.cs プロジェクト: OpenSharp/NDceRpc
        public void NamedPipe_byteArray()
        {
            using (var server = new ServiceHost(new Service(), new Uri("net.pipe://127.0.0.1/testpipename")))
            {
                var binding = new NetNamedPipeBinding {MaxConnections = 5};
                server.AddServiceEndpoint(typeof(IService),binding, "net.pipe://127.0.0.1/testpipename");
                server.Open();
                Thread.Sleep(100);
                using (var channelFactory = new ChannelFactory<IService>(binding))
                {

                    var client = channelFactory.CreateChannel(new EndpointAddress("net.pipe://127.0.0.1/testpipename"));
                    client.Execute(new byte[0]);

                    byte[] bytes = new byte[512];
                    new Random().NextBytes(bytes);

                    Stopwatch timer = new Stopwatch();
                    timer.Start();

                    for (int i = 0; i < 5000; i++)
                        client.Execute(bytes);

                    timer.Stop();
                    Trace.WriteLine(timer.ElapsedMilliseconds.ToString()+ " ms", MethodBase.GetCurrentMethod().Name);
                }
            }
        }
コード例 #18
0
ファイル: AsyncTests.cs プロジェクト: OpenSharp/NDceRpc
        public void CallAsync_wait_done()
        {
            var address = @"net.pipe://127.0.0.1/" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var binding = new NetNamedPipeBinding();

            var done = new ManualResetEvent(false);
            var srv = new AsyncService(done);
            var callback = new AsyncServiceCallback();

            using (var host = new ServiceHost(srv, new Uri(address)))
            {
                host.AddServiceEndpoint(typeof(IAsyncService), binding, address);
                host.Open();

                ThreadPool.QueueUserWorkItem(_ =>
                    {
                        using (var factory = new DuplexChannelFactory<IAsyncService>(new InstanceContext(callback), binding))
                        {
                            var client = factory.CreateChannel(new EndpointAddress(address));
                            AsyncCallback act = (x) =>
                            {
                                Assert.AreEqual(x.AsyncState, 1);
                            };
                            var result = client.BeginServiceAsyncMethod(act, 1);
                            result.AsyncWaitHandle.WaitOne();
                            Assert.AreEqual(result.AsyncState, 1);
                            client.EndServiceAsyncMethod(result);

                        }
                    });

                done.WaitOne();
            }
        }
コード例 #19
0
ファイル: SecurityTests.cs プロジェクト: OpenSharp/NDceRpc
        public void Open_Open_error()
        {
            var tcp= new NetTcpBinding();
            var pipe = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);

            Assert.IsTrue(tcp.Security.GetType() != pipe.Security.GetType());
        }
コード例 #20
0
ファイル: LyrebirdChannel.cs プロジェクト: samuto/Lyrebird
        // Public Creator
        public bool Create()
        {
            bool rc = false;
            try
            {
                _binding = new NetNamedPipeBinding();
                _binding.MaxReceivedMessageSize = 10485760;
                if (productId == 0)
                {
                    //_endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2013/LyrebirdService");
                }
                else if (productId == 2)
                {
                    _endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2015/LyrebirdService");
                }
                else if (productId == 3)
                {
                    _endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2016/LyrebirdService");
                }

                else
                {
                    _endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2014/LyrebirdService");
                }
                _factory = new ChannelFactory<ILyrebirdService>(_binding, _endpoint);
                _channel = _factory.CreateChannel();
                
                rc = true;
            }
            catch (Exception ex)
            { 
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            return rc;
        }
コード例 #21
0
		/// <summary>
		/// Configures and returns an instance of the specified service channel factory, according to the specified arguments.
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		public ChannelFactory ConfigureChannelFactory(ServiceChannelConfigurationArgs args)
		{
			var binding = new NetNamedPipeBinding();
			binding.TransferMode = args.TransferMode;
			//binding.Security.Mode = args.AuthenticationRequired ? NetNamedPipeSecurityMode.Transport : NetNamedPipeSecurityMode.None;
			//binding.Security.Transport.ProtectionLevel = args.AuthenticationRequired ? ProtectionLevel.EncryptAndSign : ProtectionLevel.None;

			// turn off transport security altogether
			//binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;


			//binding.MaxReceivedMessageSize = args.MaxReceivedMessageSize;
			//if (args.SendTimeoutSeconds > 0)
			//	binding.SendTimeout = TimeSpan.FromSeconds(args.SendTimeoutSeconds);

			// allow individual string content to be same size as entire message
			//binding.ReaderQuotas.MaxStringContentLength = args.MaxReceivedMessageSize;
			//binding.ReaderQuotas.MaxArrayLength = args.MaxReceivedMessageSize;

			var channelFactory = (ChannelFactory)Activator.CreateInstance(args.ChannelFactoryClass, binding, new EndpointAddress(args.ServiceUri));
			channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = args.CertificateValidationMode;
			channelFactory.Credentials.ServiceCertificate.Authentication.RevocationMode = args.RevocationMode;

			return channelFactory;
		}
コード例 #22
0
ファイル: MainWindow.xaml.cs プロジェクト: xbadcode/Rubezh
		private ReportServicePreviewModel CreateServiceModel()
		{
			var url = "net.pipe://127.0.0.1/ReportFiresecService/";
			var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
			binding.OpenTimeout = TimeSpan.FromMinutes(10);
			binding.SendTimeout = TimeSpan.FromMinutes(10);
			binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
			binding.MaxReceivedMessageSize = Int32.MaxValue;
			binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
			binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;
			binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;
			binding.ReaderQuotas.MaxDepth = Int32.MaxValue;
			binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
			binding.Security.Mode = NetNamedPipeSecurityMode.None;

			var endpoint = new EndpointAddress(url);
			var factory = new ReportServiceClientFactory(endpoint, binding);
			return new ReportServicePreviewModel()
			{
				ServiceClientFactory = factory,
				IsParametersPanelVisible = false,
				AutoShowParametersPanel = false,
				IsDocumentMapVisible = false,
				ZoomMode = new ZoomFitModeItem(ZoomFitMode.WholePage),
			};
		}
コード例 #23
0
        public void TestInitialize()
        {
            EndpointAddress address = new EndpointAddress("net.pipe://localhost/ServiceLocatorService");
            Binding binding = new NetNamedPipeBinding();

            _factory = new ChannelFactory<IServiceLocatorService>(binding, address);
        }
コード例 #24
0
        public static IDisposable StartService(TestDetails testDetails, TestCallbackHandler testCallback)
        {
            if (_currentService != null)
            {
                _currentService.Dispose();
                _currentService = null;
            }

            _currentCallback = testCallback;
            _testDetails = testDetails;

            ServiceHost host = new ServiceHost(typeof(TestCallbackService));
            try
            {
                var binding = new NetNamedPipeBinding();
                binding.MaxReceivedMessageSize = 100000;
                host.AddServiceEndpoint(typeof(ITestCallbackService), binding, new Uri(ServiceAddress));
                host.Open();
            }
            catch (Exception)
            {
                ((IDisposable)host).Dispose();
                _currentCallback = null;
                throw;
            }
            return new ServiceWrapper(host);
        }
コード例 #25
0
 public string Inspect(ManagedApplicationInfo applicationInfo)
 {
     var binding = new NetNamedPipeBinding();
     var channelFactory = new ChannelFactory<IProcessService>(binding, ProcessServiceAddress);
     IProcessService processService = channelFactory.CreateChannel();
     return processService.Inspect(applicationInfo);
 }
コード例 #26
0
        public ServiceHost CreateServiceHost(ClusterConfiguration clusterConfiguration)
        {
            var managerNode = new ManagerNode(clusterConfiguration);
            managerNode.Start();
            var serviceHost = new ServiceHost(managerNode,
                                              new[]
                                                  {
                                                      new Uri(string.Format("http://localhost:{0}/brightstarcluster",
                                                                            Configuration.HttpPort)),
                                                      new Uri(string.Format("net.tcp://localhost:{0}/brightstarcluster",
                                                                            Configuration.TcpPort)),
                                                      new Uri(string.Format("net.pipe://localhost/{0}",
                                                                            Configuration.NamedPipeName))
                                                  });

            var basicHttpBinding = new BasicHttpContextBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };
            var netTcpContextBinding = new NetTcpContextBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };
            var netNamedPipeBinding = new NetNamedPipeBinding { TransferMode = TransferMode.StreamedResponse, MaxReceivedMessageSize = int.MaxValue, SendTimeout = TimeSpan.FromMinutes(30), ReaderQuotas = XmlDictionaryReaderQuotas.Max, Namespace = "http://www.networkedplanet.com/schemas/brightstar" };

            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), basicHttpBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), netTcpContextBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarClusterManagerService), netNamedPipeBinding, "");

            var throttlingBehavior = new ServiceThrottlingBehavior { MaxConcurrentCalls = int.MaxValue };

            serviceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
            serviceHost.Description.Behaviors.Add(throttlingBehavior);

            serviceHost.Closed += StopNode;
            return serviceHost;
            
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: knightfall/writeasync
        private static async Task RunClientAsync(Uri address, CancellationToken token)
        {
            ClientEventSource eventSource = ClientEventSource.Instance;

            NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
            binding.OpenTimeout = TimeSpan.FromSeconds(1.0d);
            binding.SendTimeout = TimeSpan.FromSeconds(1.0d);
            binding.ReceiveTimeout = TimeSpan.FromSeconds(1.0d);
            binding.CloseTimeout = TimeSpan.FromSeconds(1.0d);

            CalculatorChannelFactory factory = new CalculatorChannelFactory(binding, new EndpointAddress(address), eventSource);
            await factory.OpenAsync();

            ConnectionManager<ICalculatorClientAsync> connectionManager = new ConnectionManager<ICalculatorClientAsync>(factory);

            using (ProxyInvoker<ICalculatorClientAsync> proxy = new ProxyInvoker<ICalculatorClientAsync>(connectionManager))
            {
                Random random = new Random();

                while (!token.IsCancellationRequested)
                {
                    try
                    {
                        await proxy.InvokeAsync(c => InvokeRandomAsync(random, c));
                    }
                    catch (Exception)
                    {
                    }

                    await Task.Delay(TimeSpan.FromMilliseconds(250.0d));
                }
            }

            await factory.CloseAsync();
        }
コード例 #28
0
 public static Binding GetBinding()
 {
     NetNamedPipeBinding binding = new NetNamedPipeBinding();
       // Для ускорения отключим безопасность.
       binding.Security.Mode = NetNamedPipeSecurityMode.None;
       return binding;
 }
コード例 #29
0
ファイル: Program.cs プロジェクト: rpwjanzen/blinken
        private static bool TrySetColor(Color color)
        {
            try
            {
                const string uriText = "net.pipe://localhost/mailnotifier/sign";
                NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                EndpointAddress endpointAddress = new EndpointAddress(uriText);
                using (MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress))
                {
                    byte red = color.R;
                    byte green = color.G;
                    byte blue = color.B;

                    client.SetColor(red, green, blue);

                    client.Close();
                    return true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to set color to " + color + ": " + e.Message);
                return false;
            }
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: allisonChilton/Presage
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri(Constants.ServiceBaseAddress);

            // Create the ServiceHost.
            using (ServiceHost host = new ServiceHost(typeof(PresageService), baseAddress))
            {
                NetNamedPipeBinding binding = new NetNamedPipeBinding();
                binding.Namespace = presage_wcf_service.Constants.ServiceNamespace;

                // Add presage endpoint.
                host.AddServiceEndpoint(
                    typeof(IPresageService),
                    binding,
                    Constants.ServicePresageEndpointRelativeAddress);

                // Enable metadata publishing.
                // Check to see if the service host already has a ServiceMetadataBehavior
                ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
                // If not, add one
                if (smb == null)
                    smb = new ServiceMetadataBehavior();
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                host.Description.Behaviors.Add(smb);

                // Add metadata endpoint.
                host.AddServiceEndpoint(
                    typeof(IMetadataExchange),
                    MetadataExchangeBindings.CreateMexNamedPipeBinding(),
                    Constants.ServiceMexEndpointRelativeAddress);

                // Open the ServiceHost to start listening for messages. Since
                // no endpoints are explicitly configured, the runtime will create
                // one endpoint per base address for each service contract implemented
                // by the service.
                try
                {
                    host.Open();
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(
                        "Error occurred while attempting to start Presage WCF Service:\n\n" + e.Message);
                    // Exit with
                    // ERROR_PIPE_BUSY
                    // 231 (0xE7)
                    // All pipe instances are busy.
                    //
                    System.Environment.Exit(231);
                }

                Console.WriteLine("Presage service is ready at {0}", baseAddress);
                Console.WriteLine("Press <Enter> to stop the service.");
                Console.ReadLine();

                // Close the ServiceHost.
                host.Close();
            }
        }
コード例 #31
0
ファイル: AppSingleton.cs プロジェクト: ittray/LocalDemo
      static void HostActivationMonitor()
      {
         NetNamedPipeBinding binding = new NetNamedPipeBinding();

         m_Host = new ServiceHost<ActivationMonitorService>();
         m_Host.AddServiceEndpoint(typeof(IActivationMonitor),binding,MonitorServiceAddress);
         m_Host.Open();
      }
コード例 #32
0
 /// <summary>
 /// Open the service host.
 /// </summary>
 /// <param name="binding">A specific biding instance.</param>
 /// <param name="address">The endpoint address.</param>
 public void OpenServiceHost(System.ServiceModel.NetNamedPipeBinding binding, string address)
 {
     if (base.CommunicationState == CommunicationState.Closed)
     {
         base.Initialise();
         base.ServiceHost.AddServiceEndpoint(typeof(Nequeo.Management.NamedPipe.IServer), binding, address);
         OpenConnection();
     }
 }
コード例 #33
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="endPointAddress">The specific end point address</param>
 /// <param name="netNamedPipeBinding">The netNamedPipeBinding binding.</param>
 /// <param name="username">The UserName username</param>
 /// <param name="password">The UserName password</param>
 /// <param name="usernameWindows">The Windows ClientCredential username</param>
 /// <param name="passwordWindows">The Windows ClientCredential password</param>
 /// <param name="clientCertificate">The client x509 certificate.</param>
 public Client(string endPointAddress, System.ServiceModel.NetNamedPipeBinding netNamedPipeBinding,
               string username                    = null, string password = null,
               string usernameWindows             = null, string passwordWindows = null,
               X509Certificate2 clientCertificate = null) :
     base(
         new Uri(endPointAddress),
         netNamedPipeBinding, username, password, usernameWindows, passwordWindows, clientCertificate)
 {
     OnCreated();
 }
コード例 #34
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="netNamedPipeBinding">The netNamedPipeBinding binding.</param>
 /// <param name="username">The UserName username</param>
 /// <param name="password">The UserName password</param>
 /// <param name="usernameWindows">The Windows ClientCredential username</param>
 /// <param name="passwordWindows">The Windows ClientCredential password</param>
 /// <param name="clientCertificate">The client x509 certificate.</param>
 public Client(System.ServiceModel.NetNamedPipeBinding netNamedPipeBinding,
               string username                    = null, string password = null,
               string usernameWindows             = null, string passwordWindows = null,
               X509Certificate2 clientCertificate = null) :
     base(
         new Uri(Nequeo.Management.NamedPipe.Properties.Settings.Default.ServiceAddress),
         netNamedPipeBinding, username, password, usernameWindows, passwordWindows, clientCertificate)
 {
     OnCreated();
 }
コード例 #35
0
        static void Main(string[] args)
        {
            Console.WriteLine("Server Started and Listening.....");

            #region CalculatorService Registration
            //Host service or Service Instance
            wcf.ServiceHost _wcfServiceHost = new wcf.ServiceHost(typeof(CalculatorLib.Calculator));
            //Add Endpoint
            System.Type _contract = typeof(CalculatorServiceContractLib.ICalculate);
            //Bidning
            wcf.NetNamedPipeBinding _localMachineBidning = new wcf.NetNamedPipeBinding();
            //Address
            string address = "net.pipe://localhost/onmachinecchannel";

            //wcf.Description.ServiceEndpoint _localMachineCommunicationChannel =
            //    new wcf.Description.ServiceEndpoint(
            //    new wcf.Description.ContractDescription(_contract.FullName),
            //    _localMachineBidning,
            //    new wcf.EndpointAddress(address)
            //    );
            //_wcfServiceHost.AddServiceEndpoint(_localMachineCommunicationChannel);
            _wcfServiceHost.AddServiceEndpoint(_contract, _localMachineBidning, address);

            //LAN Clients
            _wcfServiceHost.AddServiceEndpoint(_contract, new NetTcpBinding(), "net.tcp://localhost:5000/lanep");
            //WAN
            _wcfServiceHost.AddServiceEndpoint(_contract, new BasicHttpBinding(), "http://localhost:8001/wanep");

            //Service Behavior to publish metadata (WSDL Document)
            wcf.Description.ServiceMetadataBehavior _metadataBehavior = new wcf.Description.ServiceMetadataBehavior();
            //Configure Behavior to publish metadata when ServiceHost recieves http-get request
            _metadataBehavior.HttpGetEnabled = true;
            //Define URL to download metadata;
            _metadataBehavior.HttpGetUrl = new Uri("http://localhost:8002/metadata"); // this address used only for metadata download

            //Add Behavior -> ServieHost
            _wcfServiceHost.Description.Behaviors.Add(_metadataBehavior);

            _wcfServiceHost.Open();// ServiceHost availability for Client Requests
            #endregion
            #region PatientDataServiceRegistration


            wcf.ServiceHost _patientDataServiceHost =
                /* References Behvaior  End Point Details From app.config file */
                new ServiceHost(typeof(PatientDataServiceLib.PatientDataService));
            _patientDataServiceHost.Description.Behaviors.Add(new CustomServiceBehavior());
            _patientDataServiceHost.Open();
            #endregion

            Console.ReadKey();
        }
コード例 #36
0
        static void Main(string[] args)
        {
            //using namedpipe endpoint for the communication

            wcf.EndpointAddress     _address     = new wcf.EndpointAddress("net.pipe://localhost/onmachinecchannel");
            wcf.NetNamedPipeBinding _pipeBinding = new wcf.NetNamedPipeBinding();

            //Building Proxy Object Using ChannelFactory class
            CalculatorServiceContractLib.ICalculate _proxy =
                wcf.ChannelFactory <CalculatorServiceContractLib.ICalculate> .CreateChannel
                    (_pipeBinding, _address);

            int result = _proxy.Add(10, 20);

            Console.WriteLine(result);
            Console.ReadKey();
        }
コード例 #37
0
        public void TestTimeoutSet()
        {
            var uri     = "net.pipe://127.0.0.1/testpipename" + MethodBase.GetCurrentMethod().Name;
            var binding = new System.ServiceModel.NetNamedPipeBinding()
            {
                MaxConnections = 5
            };
            var timeout = 700;

            binding.ReceiveTimeout = TimeSpan.FromMilliseconds(timeout);
            var hang = TimeSpan.FromMilliseconds(timeout * 2);

            using (var server = new System.ServiceModel.ServiceHost(new Service(), new Uri(uri)))
            {
                server.AddServiceEndpoint(typeof(IService), binding, uri);
                server.Open();
                var channelFactory = new System.ServiceModel.ChannelFactory <IService>(binding);

                var client = channelFactory.CreateChannel(new EndpointAddress(uri));
                var result = client.Execute(TimeSpan.FromMilliseconds(0));
                Assert.AreEqual(TimeSpan.FromMilliseconds(0), result);
                CommunicationException timeoutHappenedException = null;
                try
                {
                    result = client.Execute(hang);
                }
                catch (CommunicationException ex)
                {
                    timeoutHappenedException = ex;
                }
                Assert.NotNull(timeoutHappenedException);
                Assert.AreEqual(typeof(System.IO.IOException), timeoutHappenedException.InnerException.GetType());
                var channel = client as IContextChannel;
                Assert.AreEqual(CommunicationState.Faulted, channel.State);
                try
                {
                    result = client.Execute(TimeSpan.FromMilliseconds(0));
                }
                catch (CommunicationObjectFaultedException afterTimeoutExeption)
                {
                }
                client = channelFactory.CreateChannel(new EndpointAddress(uri));
                result = client.Execute(TimeSpan.FromMilliseconds(0));
            }
        }
コード例 #38
0
 public RFServiceClient()
 {
     try
     {
         var binding        = new System.ServiceModel.NetNamedPipeBinding("riffBinding");
         var uri            = RFSettings.GetAppSetting("RFServiceUri");
         var endpoint       = new System.ServiceModel.EndpointAddress(uri);
         var channelFactory = new ChannelFactory <IRFService>(binding, endpoint);
         RFService = channelFactory.CreateChannel();
     }
     catch
     {
         if (RFService != null)
         {
             ((ICommunicationObject)RFService).Abort();
         }
         throw;
     }
 }
コード例 #39
0
        //- $StartServices -//
        private void StartServices()
        {
            ManagementService service = new ManagementService();

            managementHost = new ServiceHost(service, new Uri("net.pipe://localhost/ManagementService"));
            System.ServiceModel.NetNamedPipeBinding binding = new System.ServiceModel.NetNamedPipeBinding
            {
                ReceiveTimeout = TimeSpan.FromMinutes(5)
            };
            binding.ReaderQuotas.MaxStringContentLength = 1048576;
            managementHost.AddServiceEndpoint(typeof(IManagementService), binding, String.Empty);
            managementHost.Open();
            //+
            RequestManagementService requestService = new RequestManagementService(this);

            requestHost = new ServiceHost(requestService, new Uri("net.pipe://localhost/RequestManagementService"));
            requestHost.AddServiceEndpoint(typeof(IRequestManagementService), binding, String.Empty);
            requestHost.Open();
        }
コード例 #40
0
        private static void GetNetNamedPipeBindingDetails(NetNamedPipeBinding binding, ref string name, ref string mode, ref string credentialType)
        {
            name = GetBindingName <NetNamedPipeBinding>(binding);

            NetNamedPipeSecurity netNamedPipeSecurity = binding.Security;

            mode = netNamedPipeSecurity?.ToString();
            switch (netNamedPipeSecurity?.Mode)
            {
            case NetNamedPipeSecurityMode.None:
                credentialType = "N/A";
                break;

            case NetNamedPipeSecurityMode.Transport:
                credentialType = netNamedPipeSecurity.Transport?.ProtectionLevel.ToString();
                break;
                // No message mode
            }
        }
コード例 #41
0
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            binding = null;
            if (elements.Count > 4)
            {
                return(false);
            }

            TransactionFlowBindingElement       context   = null;
            BinaryMessageEncodingBindingElement encoding  = null;
            WindowsStreamSecurityBindingElement security  = null;
            NamedPipeTransportBindingElement    namedPipe = null;

            foreach (BindingElement element in elements)
            {
                if (element is TransactionFlowBindingElement)
                {
                    context = element as TransactionFlowBindingElement;
                }
                else if (element is BinaryMessageEncodingBindingElement)
                {
                    encoding = element as BinaryMessageEncodingBindingElement;
                }
                else if (element is WindowsStreamSecurityBindingElement)
                {
                    security = element as WindowsStreamSecurityBindingElement;
                }
                else if (element is NamedPipeTransportBindingElement)
                {
                    namedPipe = element as NamedPipeTransportBindingElement;
                }
                else
                {
                    return(false);
                }
            }

            if (namedPipe == null)
            {
                return(false);
            }

            if (encoding == null)
            {
                return(false);
            }

            if (context == null)
            {
                context = GetDefaultTransactionFlowBindingElement();
            }

            NetNamedPipeSecurity pipeSecurity;

            if (!TryCreateSecurity(security, out pipeSecurity))
            {
                return(false);
            }

            NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding(pipeSecurity);

            netNamedPipeBinding.InitializeFrom(namedPipe, encoding, context);

            if (!netNamedPipeBinding.IsBindingElementsMatch(namedPipe, encoding, context))
            {
                return(false);
            }

            binding = netNamedPipeBinding;
            return(true);
        }