Beispiel #1
0
        private void Start(string baseAddress, string path)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Start");

            try
            {
                if (_host == null)
                {
                    lock (_lock)
                    {
                        if (_host == null)
                        {
                            // Binding
                            NetTcpBinding binding = AppNotifyServiceHelper.CreateBinding();

                            // Host
                            Uri uriTcp = new Uri(new Uri(Uri.UriSchemeNetTcp + "://" + baseAddress), path);
                            //Uri uriHttp = new Uri(new Uri(Uri.UriSchemeHttp + "://" + baseAddress), path);
                            _host = new WcfServiceHost(typeof(AppNotifyService), _knownTypes, new Uri[] { uriTcp });

                            // ServiceMetadataBehavior
                            ServiceMetadataBehavior bServiceMetadata = _host.Description.Behaviors.Find <ServiceMetadataBehavior>();
                            if (bServiceMetadata == null)
                            {
                                bServiceMetadata = new ServiceMetadataBehavior();
                                _host.Description.Behaviors.Add(bServiceMetadata);
                            }
                            bServiceMetadata.HttpGetEnabled = false;
                            //bServiceMetadata.HttpGetUrl = uriHttp;

                            // ServiceDebugBehavior
                            ServiceDebugBehavior bServiceDebug = _host.Description.Behaviors.Find <ServiceDebugBehavior>();
                            if (bServiceDebug == null)
                            {
                                bServiceDebug = new ServiceDebugBehavior();
                                _host.Description.Behaviors.Add(bServiceDebug);
                            }
                            bServiceDebug.IncludeExceptionDetailInFaults = false;

                            // service points
                            _host.AddServiceEndpoint(typeof(IAppNotifyService), binding, string.Empty);
                            _host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
                        }
                    }
                }

                if (_host != null &&
                    _host.State == CommunicationState.Created)
                {
                    _host.Open();
                    Log.InfoV(PROC, "Service started at : {0}", _host.BaseAddresses[0]);
                    _mreShutdown.Reset();
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
Beispiel #2
0
 internal AppNotifyServiceClient(System.ServiceModel.InstanceContext callbackInstance, string remoteAddress) :
     this(callbackInstance, AppNotifyServiceHelper.CreateBinding(), new EndpointAddress(remoteAddress))
 {
 }