public static ServiceHost CreateServiceHost(this WcfServiceConfigElement item) { //start service listener if (string.IsNullOrEmpty(item.ServiceAddressPort) || string.IsNullOrEmpty(item.EndpointName)) { return(null); //no launch will occur if config is not there } Type hostType = Type.GetType(item.HostTypeDeclaration); Type contractType = Type.GetType(item.ContractTypeDeclaration); Uri tcpBaseAddress = new Uri(string.Format("net.tcp://{0}/", item.ServiceAddressPort)); ServiceHost host = new ServiceHost(hostType, tcpBaseAddress); NetTcpBinding tcpBinding = TcpBindingUtility.CreateNetTcpBinding(); //tcpBinding.PortSharingEnabled = true; //Metada ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpGetEnabled = false; host.Description.Behaviors.Add(smb); //Metada host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), string.Format("net.tcp://{0}/{1}/mex", item.ServiceAddressPort, item.EndpointName)); //Service host.AddServiceEndpoint(contractType, tcpBinding, string.Format("net.tcp://{0}/{1}", item.ServiceAddressPort, item.EndpointName)); //this is the default but good to know host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseWindowsGroups; return(host); }
public void Add(WcfServiceConfigElement element) { this.BaseAdd(element); }
public void Add(WcfServiceConfigElement element) { this.BaseAdd(element); }