Exemplo n.º 1
0
 private void StartStoreWorkerService()
 {
     try
     {
         Trace.TraceInformation("Starting StoreWorkerService listener");
         var endpoint         = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["StoreWorkerService"].IPEndpoint;
         var baseAddress      = new Uri(String.Format("http://{0}", endpoint));
         var basicHttpBinding = new BasicHttpContextBinding
         {
             TransferMode           = TransferMode.StreamedResponse,
             MaxReceivedMessageSize = Int32.MaxValue,
             SendTimeout            = TimeSpan.FromMinutes(10),
             ReaderQuotas           = XmlDictionaryReaderQuotas.Max,
             HostNameComparisonMode = HostNameComparisonMode.Exact
         };
         _storeWorkerService = new ServiceHost(new StoreWorkerService(), baseAddress);
         _storeWorkerService.AddServiceEndpoint(typeof(IStoreWorkerService), basicHttpBinding, String.Empty);
         var throttlingBehavior = new ServiceThrottlingBehavior {
             MaxConcurrentCalls = int.MaxValue
         };
         _storeWorkerService.Description.Behaviors.Add(throttlingBehavior);
         _storeWorkerService.Open();
         Trace.TraceInformation("StoreWorkerService started listening on endpoint http://{0}", endpoint);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error starting StoreWorkerService: " + ex);
         throw;
     }
 }
        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            BasicHttpContextBinding basicHttpContextBinding = (BasicHttpContextBinding)binding;

            SetPropertyValueIfNotDefaultValue(BasicHttpContextBindingElement.ContextManagementEnabledName, basicHttpContextBinding.ContextManagementEnabled);
        }
        public ServiceHost CreateServiceHost(IBrightstarService service, int httpPort, int tcpPort, string pipeName)
        {
            var serviceHost = new ServiceHost(service, new[] { new Uri(string.Format("http://localhost:{0}/brightstar", httpPort)),
                                                               new Uri(string.Format("net.tcp://localhost:{0}/brightstar", tcpPort)),
                                                               new Uri(string.Format("net.pipe://localhost/{0}", pipeName)) });

            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(IBrightstarService), basicHttpBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarService), netTcpContextBinding, "");
            serviceHost.AddServiceEndpoint(typeof(IBrightstarService), netNamedPipeBinding, "");

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

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

            return(serviceHost);
        }
Exemplo n.º 4
0
        public static Binding WcfBindingFactory(string bindingtype, string bidingconfigname)
        {
            Binding binding = null;

            if (!string.IsNullOrEmpty(bindingtype) && !string.IsNullOrEmpty(bidingconfigname))
            {
                switch (bindingtype)
                {
                case "basicHttpBinding":
                    binding = new BasicHttpBinding(bidingconfigname);
                    break;

                case "basicHttpContextBinding":
                    binding = new BasicHttpContextBinding(bidingconfigname);
                    break;

                case "wsHttpBinding":
                    binding = new WSHttpBinding(bidingconfigname);
                    break;

                case "wsHttpContextBinding":
                    binding = new WSHttpContextBinding(bidingconfigname);
                    break;

                case "netTcpBinding":
                    binding = new NetTcpBinding(bidingconfigname);
                    break;

                case "netTcpContextBinding":
                    binding = new NetTcpContextBinding(bidingconfigname);
                    break;

                case "netPeerTcpBinding":
                    binding = new NetPeerTcpBinding(bidingconfigname);
                    break;

                case "netNamedPipeBinding":
                    binding = new NetNamedPipeBinding(bidingconfigname);
                    break;

                case "webHttpBinding":
                    binding = new WSHttpBinding(bidingconfigname);
                    break;

                case "wsDualHttpBinding":
                    binding = new WSDualHttpBinding(bidingconfigname);
                    break;

                case "customBinding":
                    binding = new CustomBinding(bidingconfigname);
                    break;
                }
            }

            return(binding);
        }
Exemplo n.º 5
0
        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            BasicHttpContextBinding binding2 = (BasicHttpContextBinding)binding;

            if (!binding2.ContextManagementEnabled)
            {
                this.ContextManagementEnabled = binding2.ContextManagementEnabled;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialises and returns a new HTTP service client. This client should be used when the client is on a separate machine from the service and
        /// firewall or other constrains prohibit the use of the TcpNet client.
        /// </summary>
        /// <param name="endpointUri">The uri where the HTTP endpoint is running. By default this is http://{machinename}:8090/brightstar</param>
        /// <param name="queryCache">OPTIONAL : the cache to use for query results</param>
        /// <returns>A new brightstar service client. It is important to call dispose on the client after use.</returns>
        internal static IBrightstarService GetHttpClient(Uri endpointUri, ICache queryCache = null)
        {
            var binding = new BasicHttpContextBinding
            {
                MaxReceivedMessageSize = Int32.MaxValue,
                SendTimeout            = TimeSpan.FromMinutes(30),
                TransferMode           = TransferMode.StreamedResponse,
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max
            };
            var endpointAddress = new EndpointAddress(endpointUri);
            var client          = new BrightstarServiceClient(new BrightstarWcfServiceClient(binding, endpointAddress), queryCache);

            return(client);
        }
Exemplo n.º 7
0
        private static Binding GetBasicHttpContextBinding()
        {
            var binding = new BasicHttpContextBinding();

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.Security.Mode          = BasicHttpSecurityMode.None;
            binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
            binding.TransferMode          = TransferMode.Buffered;
            binding.ReaderQuotas.MaxDepth = int.MaxValue;
            binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            binding.ReaderQuotas.MaxArrayLength         = int.MaxValue;
            binding.ReaderQuotas.MaxBytesPerRead        = int.MaxValue;
            binding.ReaderQuotas.MaxNameTableCharCount  = int.MaxValue;
            return(binding);
        }
Exemplo n.º 8
0
        private BlockUpdateServiceClient GetBlockServiceClient(RoleInstance workerInstance)
        {
            var binding = new BasicHttpContextBinding
            {
                TransferMode           = TransferMode.StreamedResponse,
                MaxReceivedMessageSize = Int32.MaxValue,
                SendTimeout            = TimeSpan.FromMinutes(10),
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max,
                HostNameComparisonMode = HostNameComparisonMode.Exact
            };
            var endpointUri     = String.Format("http://{0}", workerInstance.InstanceEndpoints[AzureConstants.BlockServiceEndpoint].IPEndpoint);
            var endpointAddress = new EndpointAddress(endpointUri);
            var client          = new BlockUpdateServiceClient(binding, endpointAddress);

            return(client);
        }
        private static BrightstarClusertManagerServiceClient GetClusterClient()
        {
            const string endpointUri = "http://127.0.0.1:9090/brightstarcluster";
            var          binding     = new BasicHttpContextBinding
            {
                MaxReceivedMessageSize = Int32.MaxValue,
                SendTimeout            = TimeSpan.FromMinutes(30),
                TransferMode           = TransferMode.StreamedResponse,
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max
            };
            var endpointAddress = new EndpointAddress(endpointUri);

            var client = new BrightstarClusertManagerServiceClient(binding, endpointAddress);

            return(client);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Для обращения к сервису
        /// </summary>
        /// <returns></returns>
        private EncyclopediaServiceClient GetClient()
        {
            string sUrlService = "http://127.0.0.1:8000/Service1";
            BasicHttpContextBinding pBinding = new BasicHttpContextBinding();

            //Увеличение количества возможных байтов для отправки
            ServicePointManager.CheckCertificateRevocationList = false;
            pBinding.MaxReceivedMessageSize = int.MaxValue;
            pBinding.Name         = "BasicHttpBinding_IEncyclopediaService";
            pBinding.ReaderQuotas = XmlDictionaryReaderQuotas.Max;
            //pBinding.ReceiveTimeout = new TimeSpan(0, 3, 0);
            //pBinding.SendTimeout = new TimeSpan(0, 3, 0);

            EndpointAddress           pEndpointAddress = new EndpointAddress(sUrlService);
            EncyclopediaServiceClient pClient          = new EncyclopediaServiceClient(pBinding, pEndpointAddress);

            return(pClient);
        }
        public void TestUnavailableWithNoNodes()
        {
            StartClusterManagerService();
            var endpointUri = "http://127.0.0.1:9090/brightstarcluster";
            var binding     = new BasicHttpContextBinding
            {
                MaxReceivedMessageSize = Int32.MaxValue,
                SendTimeout            = TimeSpan.FromMinutes(30),
                TransferMode           = TransferMode.StreamedResponse,
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max
            };
            var endpointAddress = new EndpointAddress(endpointUri);

            var client             = new BrightstarClusertManagerServiceClient(binding, endpointAddress);
            var clusterDescription = client.GetClusterDescription();

            Assert.IsNotNull(clusterDescription);
            Assert.AreEqual(ClusterStatus.Unavailable, clusterDescription.Status);
        }
Exemplo n.º 12
0
        public KBDAPIService(KBDAPIServiceConfig kbdServiceConfig, SearchServiceConfig searchServiceConfig) : base("[KBDAPIService]")
        {
            if (kbdServiceConfig == null || searchServiceConfig == null)
            {
                throw new Exception("Wrong application config file, it should have ServiceConfig parameters!");
            }
            _searchServiceConfig = searchServiceConfig;

            /* BASIC HTTP CONTEXT BINDING */
            BasicHttpContextBinding binding = new BasicHttpContextBinding(BasicHttpSecurityMode.TransportCredentialOnly);

            binding.Name = "KBDAPI_docsSoap";
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

            string endpointAddress = $"http://{ kbdServiceConfig.ServiceUrl }/{ kbdServiceConfig.EndpointUrl}";

            LOG_TRACE($"endpointAddress: {endpointAddress}");
            EndpointAddress ea = new EndpointAddress(endpointAddress);

            _client = new KBDAPI_docsSoapClient(binding, ea);

            _client.ClientCredentials.UserName.UserName = "******";
            _client.ClientCredentials.UserName.Password = "******";


            if (searchServiceConfig == null)
            {
                LOG_ERROR($"SearchServiceConfig is null");
                throw new Exception("Wrong applicaton config file, it should have SearchServiceConfig parameters!");
            }
            BasicHttpContextBinding ssBinding = new BasicHttpContextBinding(BasicHttpSecurityMode.TransportCredentialOnly);

            ssBinding.Name = "apiSoap";
            ssBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            string          ssEndpointAddress = $"http://{searchServiceConfig.ServiceUrl}/{searchServiceConfig.EndpointUrl}";
            EndpointAddress ssEa = new EndpointAddress(ssEndpointAddress);

            _searchClient = new apiSoapClient(ssBinding, ssEa);
            _searchClient.ClientCredentials.UserName.UserName = searchServiceConfig.Username;
            _searchClient.ClientCredentials.UserName.Password = searchServiceConfig.Password;
            _httpClient = new HttpClient(searchServiceConfig.ServiceUrl);
        }
Exemplo n.º 13
0
        private void AddClient(RoleInstance workerInstance)
        {
            var binding = new BasicHttpContextBinding
            {
                TransferMode           = TransferMode.StreamedResponse,
                MaxReceivedMessageSize = Int32.MaxValue,
                SendTimeout            = TimeSpan.FromMinutes(10),
                ReaderQuotas           = XmlDictionaryReaderQuotas.Max,
                HostNameComparisonMode = HostNameComparisonMode.Exact
            };
            var endpointUri     = String.Format("http://{0}", workerInstance.InstanceEndpoints["StoreWorkerService"].IPEndpoint);
            var endpointAddress = new EndpointAddress(endpointUri);
            var client          = new StoreWorkerServiceClient(binding, endpointAddress);

            lock (_clients)
            {
                _clients.RemoveAll(t => t.Item1.Equals(workerInstance.Id));
                _clients.Add(new Tuple <string, IStoreWorkerService>(workerInstance.Id, client));
            }
        }
        private void CreateEndpoints()
        {
            Type contractType = ServiceUtility.GetContractType(ImplementedContracts);
            AuthenticationSchemes oneAuthScheme;

            ClientRequestServiceBehaviorAttribute.GetAllAuthenticationSchemes(out oneAuthScheme);

            foreach (Uri baseAddress in this.m_baseAddresses)
            {
                BasicHttpContextBinding binding = new BasicHttpContextBinding
                {
                    AllowCookies           = true,
                    ReceiveTimeout         = TimeSpan.FromHours(1),
                    SendTimeout            = TimeSpan.FromHours(1),
                    OpenTimeout            = TimeSpan.FromHours(1),
                    CloseTimeout           = TimeSpan.FromHours(1),
                    MaxReceivedMessageSize = int.MaxValue,
                    ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas
                    {
                        MaxArrayLength         = int.MaxValue,
                        MaxBytesPerRead        = 2048,
                        MaxDepth               = int.MaxValue,
                        MaxNameTableCharCount  = int.MaxValue,
                        MaxStringContentLength = int.MaxValue,
                    }
                };

                if (baseAddress.Scheme == Uri.UriSchemeHttps)
                {
                    binding.Security.Mode = BasicHttpSecurityMode.Transport;
                }
                else if (baseAddress.Scheme == Uri.UriSchemeHttp)
                {
                    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                }
                else if ((oneAuthScheme != AuthenticationSchemes.None) && (oneAuthScheme != AuthenticationSchemes.Anonymous))
                {
                    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                }
                else
                {
                    binding.Security.Mode = BasicHttpSecurityMode.None;
                }
                binding.Security.Transport.ClientCredentialType = ServiceUtility.ClientCredentialTypeFromAuthenticationScheme(oneAuthScheme);
                this.AddServiceEndpoint(contractType, binding, baseAddress);
                ServiceUtility.EnableMetadataExchange(this, baseAddress, oneAuthScheme, true);

                //TODO: Add a REST endpoint (Workflow instantiated/consumed by a REST based client = AWESOME!)
                //The following is a start -- but the problem is that the custom binding 1) needs to have behavior configured to be httpGet enabled, as well as the service host have webHttp
                //Uri restAddress = new Uri(baseAddress, "/" + baseAddress.GetComponents(UriComponents.Path, UriFormat.Unescaped) + "/rest");

                //ContextBindingElement context = new ContextBindingElement();
                //context.ContextExchangeMechanism = ContextExchangeMechanism.HttpCookie;
                //context.ProtectionLevel = System.Net.Security.ProtectionLevel.None;

                //WebMessageEncodingBindingElement webMessageEncoding = new WebMessageEncodingBindingElement();

                //HttpTransportBindingElement httpTransport;
                //if (baseAddress.Scheme == Uri.UriSchemeHttp)
                //{
                //    httpTransport = new HttpTransportBindingElement();

                //}
                //else
                //{
                //    httpTransport = new HttpsTransportBindingElement();
                //}
                //httpTransport.AuthenticationScheme = oneAuthScheme;

                //BindingElementCollection elements = new BindingElementCollection();
                //elements.Add(context);
                //elements.Add(webMessageEncoding);
                //elements.Add(httpTransport);

                //CustomBinding restEndpointBinding = new CustomBinding(elements);
                //this.AddServiceEndpoint(contractType, restEndpointBinding, restAddress);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get a binding based on values of this class
        /// </summary>
        /// <returns>Hydrated binding</returns>
        /// <exception cref="InvalidOperationException">Thrown if requested binding doesn't match one of the implemented bindings</exception>
        public Binding GetBinding()
        {
            System.ServiceModel.Channels.Binding binder = null;
            switch (this.Binding)
            {
            case WcfBindings.BasicHttp:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new BasicHttpBinding(ConfigurationName);
                }
                else
                {
                    binder = new BasicHttpBinding()
                    {
                        BypassProxyOnLocal     = ByPassProxyOnLocal,
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        //UseDefaultWebProxy = UseDefaultProxy,
                        ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            case WcfBindings.BasicContext:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new BasicHttpContextBinding(ConfigurationName);
                }
                else
                {
                    binder = new BasicHttpContextBinding()
                    {
                        BypassProxyOnLocal     = ByPassProxyOnLocal,
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        UseDefaultWebProxy     = UseDefaultProxy,
                        ProxyAddress           = new Uri(ProxyAddress),
                        ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            case WcfBindings.NetTcp:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new NetTcpBinding(ConfigurationName);
                }
                else
                {
                    binder = new NetTcpBinding()
                    {
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            case WcfBindings.WebHttp:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new WebHttpBinding(ConfigurationName);
                }
                else
                {
                    binder = new WebHttpBinding()
                    {
                        BypassProxyOnLocal     = ByPassProxyOnLocal,
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        UseDefaultWebProxy     = UseDefaultProxy,
                        ProxyAddress           = new Uri(ProxyAddress),
                        ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            case WcfBindings.WsHttpBinding:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new WSHttpBinding(ConfigurationName);
                }
                else
                {
                    binder = new WSHttpBinding()
                    {
                        BypassProxyOnLocal     = ByPassProxyOnLocal,
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        UseDefaultWebProxy     = UseDefaultProxy,
                        ProxyAddress           = new Uri(ProxyAddress),
                        ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            case WcfBindings.WsHttpContext:
                if (!string.IsNullOrWhiteSpace(ConfigurationName))
                {
                    binder = new WSHttpContextBinding(ConfigurationName);
                }
                else
                {
                    binder = new WSHttpContextBinding()
                    {
                        BypassProxyOnLocal     = ByPassProxyOnLocal,
                        MaxBufferPoolSize      = MaxBufferSize,
                        MaxReceivedMessageSize = MaxReceivedMessageSize,
                        UseDefaultWebProxy     = UseDefaultProxy,
                        ProxyAddress           = new Uri(ProxyAddress),
                        ReaderQuotas           = new System.Xml.XmlDictionaryReaderQuotas()
                        {
                            MaxArrayLength         = MaxArrayLength,
                            MaxBytesPerRead        = MaxBytesPerRead,
                            MaxDepth               = MaxDepth,
                            MaxNameTableCharCount  = MaxNameTableCharCount,
                            MaxStringContentLength = MaxStringContentLength
                        }
                    };
                }
                break;

            default:
                throw ExceptionFactory.New <InvalidOperationException>("Unable to instantiante a binding of '{0}'", this.Binding.ToString());
            }

            binder.CloseTimeout   = CloseTimeout;
            binder.OpenTimeout    = OpenTimeout;
            binder.ReceiveTimeout = ReceiveTimeout;
            binder.SendTimeout    = SendTimeout;
            return(binder);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates the appropriate binding type for the given element
        /// </summary>
        /// <param name="endPoint">Enpoint to create binding object for</param>
        /// <returns>Binding represented in the config file</returns>
        private static Binding GetBinding(ChannelEndpointElement endPoint)
        {
            Binding binding = null;

            try
            {
                switch (endPoint.Binding)
                {
                case "basicHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new BasicHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new BasicHttpBinding();
                    }
                    break;

                case "basicHttpContextBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new BasicHttpContextBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new BasicHttpContextBinding();
                    }
                    break;

                case "customBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new CustomBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new CustomBinding();
                    }
                    break;

                case "netNamedPipeBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetNamedPipeBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetNamedPipeBinding();
                    }
                    break;

                case "netPeerTcpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetPeerTcpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetPeerTcpBinding();
                    }
                    break;

                case "netTcpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetTcpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetTcpBinding();
                    }
                    break;

                case "netTcpContextBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetTcpContextBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetTcpContextBinding();
                    }
                    break;

                case "webHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WebHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WebHttpBinding();
                    }
                    break;

                case "ws2007HttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WS2007HttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WS2007HttpBinding();
                    }
                    break;

                case "wsHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WSHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WSHttpBinding();
                    }
                    break;

                case "wsHttpContextBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WSHttpContextBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WSHttpContextBinding();
                    }
                    break;

                case "wsDualHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WSDualHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WSDualHttpBinding();
                    }
                    break;

                case "wsFederationHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WSFederationHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WSFederationHttpBinding();
                    }
                    break;

                case "ws2007FederationHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new WS2007FederationHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new WS2007FederationHttpBinding();
                    }
                    break;

                case "msmqIntegrationBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new MsmqIntegrationBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new MsmqIntegrationBinding();
                    }
                    break;

                case "netMsmqBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetMsmqBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetMsmqBinding();
                    }
                    break;

                case "netHttpBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetHttpBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetHttpBinding();
                    }
                    break;

                case "netHttpsBinding":
                    if (!string.IsNullOrEmpty(endPoint.BindingConfiguration))
                    {
                        binding = new NetHttpsBinding(endPoint.BindingConfiguration);
                    }
                    else
                    {
                        binding = new NetHttpBinding();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace + "." + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw ex;
            }

            return(binding);
        }