Esempio n. 1
0
        public ServiceEndpointDescription StartBasicHttpHost <TServiceType, TServiceInterfaceType>(string name, string description)
        {
            Platform.Log(LogLevel.Info, "Starting WCF Shred {0}...", name);

            if (_serviceEndpointDescriptions.ContainsKey(name))
            {
                throw new Exception(String.Format("The service endpoint '{0}' already exists.", name));
            }

            ServiceEndpointDescription sed =
                WcfHelper.StartBasicHttpHost <TServiceType, TServiceInterfaceType>(name, description, SharedHttpPort, ServiceAddressBase);

            _serviceEndpointDescriptions[name] = sed;

            Platform.Log(LogLevel.Info, "WCF Shred {0} is listening at {1}.", name, sed.ServiceHost.Description.Endpoints[0].Address);

            return(sed);
        }
Esempio n. 2
0
        static private ServiceEndpointDescription StartHost <TServiceType, TServiceInterfaceType>
        (
            string name,
            string description,
            HostBindingType bindingType,
            int httpPort,
            int tcpPort,
            string serviceAddressBase)
        {
            ServiceEndpointDescription sed = new ServiceEndpointDescription(name, description);

            sed.Binding     = GetBinding <TServiceInterfaceType>(bindingType);
            sed.ServiceHost = new ServiceHost(typeof(TServiceType));
            var endpointAddress = GetEndpointAddress(name, bindingType, tcpPort, httpPort, serviceAddressBase);

            ServiceMetadataBehavior metadataBehavior = sed.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>();

            if (null == metadataBehavior)
            {
                if (bindingType == HostBindingType.BasicHttp ||
                    bindingType == HostBindingType.WSHttp ||
                    bindingType == HostBindingType.WSDualHttp)
                {
                    metadataBehavior = new ServiceMetadataBehavior();
                    metadataBehavior.HttpGetEnabled = true;
                    metadataBehavior.HttpGetUrl     = endpointAddress;
                    sed.ServiceHost.Description.Behaviors.Add(metadataBehavior);
                }
            }

            ServiceDebugBehavior debugBehavior = sed.ServiceHost.Description.Behaviors.Find <ServiceDebugBehavior>();

            if (null == debugBehavior)
            {
                debugBehavior = new ServiceDebugBehavior();
                debugBehavior.IncludeExceptionDetailInFaults = true;
                sed.ServiceHost.Description.Behaviors.Add(debugBehavior);
            }

            sed.ServiceHost.AddServiceEndpoint(typeof(TServiceInterfaceType), sed.Binding, endpointAddress);
            sed.ServiceHost.Open();

            return(sed);
        }
Esempio n. 3
0
 static ShredHost()
 {
     _shredInfoList = new ShredControllerList();
     _sed           = null;
     _runningState  = RunningState.Stopped;
 }
Esempio n. 4
0
 static public void StopHost(ServiceEndpointDescription sed)
 {
     sed.ServiceHost.Close();
 }