Beispiel #1
0
        internal static GatewayService Initialise()
        {
            try
            {
                _logger.Info("------------------------------------");
                _logger.Info("starting Gateway service");
                InsertBrokerOperationLog.AddProcessLog("starting Gateway service");
                var service        = new GatewayService();
                var controllerHost = new ServiceHost(service);
                controllerHost.Open();

                _logger.Info("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri);
                _logger.Info("------------------------------------");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //amit 04112016

                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("GatewayService Initialise() Exception" + ex.Message);
            }
            return(null);
        }
Beispiel #2
0
        internal static GatewayService Initialise()
        {
            try
            {
                //amit 16042018
                _logger.Info("");
                _logger.Info("------------------------------------");
                _logger.Info("starting Gateway service.");

                var service = new GatewayService();
                // var controllerHost = new ServiceHost(service);
                // controllerHost.Open();
                //
                Uri httpUrl = new Uri("https://localhost:6530/GatewayService");

                WebServiceHost controllerHost
                    = new WebServiceHost(typeof(GatewayService), httpUrl);

                WebHttpBinding _webhttpbis = new WebHttpBinding(WebHttpSecurityMode.Transport);
                _webhttpbis.MaxReceivedMessageSize = 2147483647;//2147483647 //1073741823
                _webhttpbis.ReceiveTimeout         = TimeSpan.Parse("00:10:00");
                _webhttpbis.CloseTimeout           = TimeSpan.Parse("00:10:00");
                _webhttpbis.OpenTimeout            = TimeSpan.Parse("00:10:00");
                _webhttpbis.SendTimeout            = TimeSpan.Parse("00:10:00");
                _webhttpbis.MaxBufferPoolSize      = 524288;


                //   _webhttpbis.CrossDomainScriptAccessEnabled = true;

                var endpoint = controllerHost.AddServiceEndpoint(typeof(IGatewayService), _webhttpbis, "");//WSHttpBinding

                ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
                {
                    MaxConcurrentCalls     = 500,
                    MaxConcurrentInstances = 500,
                    MaxConcurrentSessions  = 500,
                };

                controllerHost.Description.Behaviors.Add(throttleBehavior);
                WebHttpBehavior behavior = new WebHttpBehavior();
                behavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json;

                endpoint.Behaviors.Add(behavior);

                var _ServiceMetadataBehavior = controllerHost.Description.Behaviors.Find <ServiceMetadataBehavior>();
                if (_ServiceMetadataBehavior == null)
                {
                    _ServiceMetadataBehavior = new ServiceMetadataBehavior();
                    _ServiceMetadataBehavior.HttpsGetEnabled = true;
                    _ServiceMetadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                    controllerHost.Description.Behaviors.Add(_ServiceMetadataBehavior);
                }
                else
                {
                    _ServiceMetadataBehavior.HttpsGetEnabled = true;
                    _ServiceMetadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                }
                _ServiceMetadataBehavior.HttpGetEnabled  = true;
                _ServiceMetadataBehavior.HttpsGetEnabled = true;
                controllerHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpsBinding(), "mex");//WSHttpBinding

                controllerHost.Open();
                //
                _logger.Info(string.Format("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri));
                _logger.Info("------------------------------------");
                _logger.Info("");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016
                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("GatewayService Initialise() Exception" + ex.Message);

                InsertBrokerOperationLog.AddProcessLog("GatewayService Initialise() Exception:" + ex.Message);
            }
            return(null);
        }