//TODO: Should this be removed? - Should be commented as to why it is not currently active if left in

        ///// <summary>
        ///// End processing of message
        ///// </summary>
        //internal WcfSendResult EndProcessMessage(Guid result)
        //{
        //    WcfSendResult retVal;
        //    if (results.TryGetValue(result, out retVal))
        //    {
        //        lock(results)
        //            results.Remove(result);
        //        return retVal;
        //    }

        //    return null;
        //}
        #endregion

        #region IListenWaitConnector Members

        /// <summary>
        /// Starts the service host and initializes the listen process.
        /// </summary>
        public void Start()
        {
            if (!IsOpen())
            {
                throw new ConnectorException(ConnectorException.MSG_INVALID_STATE, ConnectorException.ReasonType.NotOpen);
            }
            svcHost.Open();
        }
Exemple #2
0
        private void Run()
        {
            logger.Info("Application start");

            PhonebookImportServiceImpl sampleService = new PhonebookImportServiceImpl(logger);

            WcfServiceHost serviceHost = new WcfServiceHost();

            serviceHost.Open(sampleService);

            Console.ReadKey();

            serviceHost.Close();
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <ClientsRepository>().As <IClientsRepository>().SingleInstance();
            containerBuilder.RegisterType <NotificationFactory>().As <INotificationFactory>().SingleInstance();
            containerBuilder.RegisterType <ClientsManagement>().As <IClientsManagement>().SingleInstance();
            containerBuilder.RegisterType <ServiceActionsHandler>().As <IServiceActionsHandler>().SingleInstance();
            containerBuilder.RegisterType <ServiceContract>().As <IServiceContract>().SingleInstance();

            var container = containerBuilder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                var host = new WcfServiceHost(scope.Resolve <IServiceContract>());

                host.Open();

                Console.ReadKey();

                host.Close();
            }
        }
Exemple #4
0
        /// <summary>
        /// Starts a <see cref="ServiceHost"/> for each found service. Defaults to <see cref="BasicHttpBinding"/> if
        /// no user specified binding is found
        /// </summary>
        public void Start()
        {
            foreach (var serviceType in Configure.TypesToScan.Where(t => !t.IsAbstract && IsWcfService(t)))
            {
                _host = new WcfServiceHost(serviceType);

                Binding binding = new BasicHttpBinding();

                if (Configure.Instance.Configurer.HasComponent <Binding>())
                {
                    binding = Configure.Instance.Builder.Build <Binding>();
                }

                _host.AddDefaultEndpoint(GetContractType(serviceType),
                                         binding
                                         , "");

                _hosts.Add(_host);

                logger.InfoFormat("Initialising the WCF service: {0}", serviceType.AssemblyQualifiedName);

                _host.Open();
            }
        }
Exemple #5
0
        public bool Start()
        {
            ModuleProc PROC   = new ModuleProc(this.DYN_MODULE_NAME, "Start");
            bool       result = false;

            try
            {
                if (_host == null)
                {
                    lock (_lock)
                    {
                        if (_host == null)
                        {
                            // Host
                            string hostName = Dns.GetHostName();

                            // Add the base address
                            Type serviceType = typeof(ConfigStoreService);

                            Uri pipeUri = new Uri(ConfigStoreManager.GetPipeName(Process.GetCurrentProcess().Id));
                            Log.Info(PROC, pipeUri.AbsoluteUri);

                            // default servuce
                            if (true)
                            {
                                _host = new WcfServiceHost(serviceType, null, new Uri[] { pipeUri });
                                Type[] interfaces = serviceType.GetInterfaces();
                                string serviceContractAttrString = typeof(ServiceContractAttribute).ToString();
                                if (interfaces != null)
                                {
                                    foreach (Type iface in interfaces)
                                    {
                                        ServiceContractAttribute serviceContractAttr = (from c in iface.GetCustomAttributes(false)
                                                                                        where c.ToString() == serviceContractAttrString
                                                                                        select c).FirstOrDefault() as ServiceContractAttribute;
                                        if (serviceContractAttr != null)
                                        {
                                            // named pipe
                                            _host.AddServiceEndpoint(iface, CreateNamedPipeBinding(),
                                                                     pipeUri);
                                        }
                                    }
                                }
                            }

                            // Mex endpoings
                            _host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexNamedPipeBinding(),
                                                     "mex");
                            Log.Info(PROC, pipeUri.AbsoluteUri + "/mex");
                        }
                    }
                }

                // default service host
                try
                {
                    if (_host != null &&
                        _host.State == CommunicationState.Created)
                    {
                        _host.Open();
                        result = true;
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception(PROC, ex);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
 protected override void OnStart(string[] args)
 {
     _wcfServiceHost.Open();
 }