private WcfClient CreateClientWithCustomBinding(Uri endpointAddress, string configurationName = null) { var binding = WCFLibraryHelpers.GetCustomBinding(configurationName); var endpoint = new EndpointAddress(endpointAddress); return(new WcfClient(binding, endpoint)); }
public void StartService(string bindingType, int port, string relativePath) { relativePath = relativePath.TrimStart('/'); if (_wcfService_SelfHosted != null) { StopService(); } WCFLibraryHelpers.StartAgentWithExternalCall(); var bindingTypeEnum = (WCFBindingType)Enum.Parse(typeof(WCFBindingType), bindingType, true); var baseAddress = WCFLibraryHelpers.GetEndpointAddress(bindingTypeEnum, port, relativePath); Logger.Info($"Starting WCF Service using {bindingTypeEnum} binding at endpoint {baseAddress}"); _wcfService_SelfHosted = new ServiceHost(typeof(WcfService), baseAddress); if (bindingTypeEnum != WCFBindingType.NetTcp) { var smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; _wcfService_SelfHosted.Description.Behaviors.Add(smb); } switch (bindingTypeEnum) { case WCFBindingType.BasicHttp: _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), new BasicHttpBinding(), baseAddress); break; case WCFBindingType.WebHttp: var endpoint = _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), new WebHttpBinding(), baseAddress); var behavior = new WebHttpBehavior(); endpoint.EndpointBehaviors.Add(behavior); break; case WCFBindingType.WSHttp: _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), new WSHttpBinding(), baseAddress); break; case WCFBindingType.NetTcp: _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), new NetTcpBinding(), baseAddress); break; case WCFBindingType.Custom: _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), WCFLibraryHelpers.GetCustomBinding(), baseAddress); break; case WCFBindingType.CustomClass: _wcfService_SelfHosted.AddServiceEndpoint(typeof(IWcfService), WCFLibraryHelpers.GetCustomBinding("CustomWcfBinding"), baseAddress); break; default: throw new NotImplementedException($"Binding Type {bindingTypeEnum}"); } _wcfService_SelfHosted.Open(); }
public void StartService(string srcAppPath, string bindingType, int port, string relativePath, bool aspNetCompatibilityEnabled) { WCFLibraryHelpers.StartAgentWithExternalCall(); var bindingTypeEnum = (WCFBindingType)Enum.Parse(typeof(WCFBindingType), bindingType, true); _hostedWebCore = new HostedWebCore(); _hostedWebCore.StageWebApp(srcAppPath, port); ConfigureBinding(bindingTypeEnum, relativePath, port); ConfigureASPNetCompatibilityMode(aspNetCompatibilityEnabled); _hostedWebCore.Start(); }
private void InitializeClient(string bindingType, int port, string relativePath) { relativePath = relativePath.TrimStart('/'); var bindingTypeEnum = (WCFBindingType)Enum.Parse(typeof(WCFBindingType), bindingType); var endpointAddress = WCFLibraryHelpers.GetEndpointAddress(bindingTypeEnum, port, relativePath); switch (bindingTypeEnum) { case WCFBindingType.BasicHttp: _wcfClient = CreateClientWithHttpBinding(endpointAddress); break; case WCFBindingType.WSHttp: _wcfClient = CreateClientWithWSHttpBinding(endpointAddress); break; case WCFBindingType.WebHttp: _wcfClient = CreateClientWithWebHttpBinding(endpointAddress); break; case WCFBindingType.NetTcp: _wcfClient = CreateClientWithNetTCPBinding(endpointAddress); break; case WCFBindingType.Custom: _wcfClient = CreateClientWithCustomBinding(endpointAddress); break; case WCFBindingType.CustomClass: _wcfClient = CreateClientWithCustomBinding(endpointAddress, "CustomWcfBinding"); break; default: throw new NotImplementedException($"Binding Type {bindingTypeEnum}"); } }