protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { const int bufferSize = 512000; //500KB BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None) { SendTimeout = TimeSpan.FromSeconds(30), ReceiveTimeout = TimeSpan.FromSeconds(30), CloseTimeout = TimeSpan.FromSeconds(30), MaxReceivedMessageSize = bufferSize, MaxBufferSize = bufferSize, MaxBufferPoolSize = bufferSize * Environment.ProcessorCount, }; var webBinding = new WebHttpBinding(WebHttpSecurityMode.None); var serviceUri = string.Empty; yield return(new ServiceInstanceListener(context => { string host = context.NodeContext.IPAddressOrFQDN; serviceUri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/Core/", "http", host, 8001); var address = new EndpointAddress(serviceUri); // var webCore = new WebCore { Context = context }; var listener = new WcfCommunicationListener <ICoreService>(context, webCore, webBinding, address); var eb = listener.ServiceHost.Description.Endpoints.Last(); eb.EndpointBehaviors.Add(new WebHttpBehavior()); return listener; })); }
private static ICommunicationListener CreateSoapListener(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("CalculatorEndpoint"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/", scheme, host, port); var listener = new WcfCommunicationListener <ICalculatorService>( serviceContext: context, wcfServiceObject: new WcfCalculatorService(), listenerBinding: new BasicHttpBinding(BasicHttpSecurityMode.None), address: new EndpointAddress(uri) ); // Check to see if the service host already has a ServiceMetadataBehavior ServiceMetadataBehavior smb = listener.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); // If not, add one if (smb == null) { smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri(uri); listener.ServiceHost.Description.Behaviors.Add(smb); } return(listener); }
void ActivateServiceType(Type serviceType) { StatelessService service = Activator.CreateInstance(serviceType, new StatelessServiceContext()) as StatelessService; foreach (ServiceInstanceListener instanceListener in service.ServiceInstanceListeners) { WcfCommunicationListener listener = instanceListener.CreateCommunicationListener(new StatelessServiceContext()) as WcfCommunicationListener; if (listener != null) { if (listener.ImplementationType.Equals(serviceType) == false) { throw new InvalidOperationException("Validation failed. Service Type " + serviceType.FullName + " does not match listener implementation type " + listener.ImplementationType.FullName + "."); } ValidateContract(serviceType, listener.InterfaceType); Type concreteHostType = m_GenericServiceHostDefinition.MakeGenericType(serviceType); ServiceHost host = Activator.CreateInstance(concreteHostType) as ServiceHost; NetTcpBinding binding = listener.Binding; if (binding == null) { binding = BindingHelper.Service.Wcf.ServiceBinding(); } host.Description.Behaviors.Add(new StatelessServiceBehavior()); IEnumerable <ApplicationManifestAttribute> manifests = serviceType.GetCustomAttributes <ApplicationManifestAttribute>(); foreach (ApplicationManifestAttribute manifest in manifests) { host.AddServiceEndpoint(listener.InterfaceType, binding, AddressHelper.Wcf.BuildAddress("localhost", manifest.ApplicationName, manifest.ServiceName, listener.InterfaceType)); } host.Open(); } } }
protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() => new List <ServiceInstanceListener> { new ServiceInstanceListener((context) => { var endpointAddress = new EndpointAddress(WcfListener.HttpServiceUri(context, "MyLegacyService.svc")); var r = new WcfCommunicationListener <IMyLegacyService>( serviceContext: context, wcfServiceObject: _myLegacyService, listenerBinding: WcfListener.GetBinding(BindingType.WsHttpBinding), address: endpointAddress); ServiceMetadataBehavior smb = r.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); if (smb == null) { smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpGetEnabled = true; smb.HttpGetUrl = endpointAddress.Uri; r.ServiceHost.Description.Behaviors.Add(smb); } return(r); }, "WebHttpListenerMyLegacyService") };
private ICommunicationListener CreateWCFListenerForPlatformAuthentication(StatelessServiceContext context) { var servicePath = "Platform/Authentication"; var serviceUri = String.Format("net.tcp://{0}:{1}/Services/{2}", wcfDomain, listenerPort, servicePath); var metaExchangeUri = String.Format("net.tcp://{0}:{1}/Services/{2}/mex", wcfDomain, metaExchangePort, servicePath); var bindings = WcfUtility.CreateTcpListenerBinding(maxMessageSize: 2500000); //<-- Set to 2.5mb for larger packages //((System.ServiceModel.NetTcpBinding)binding).MaxReceivedMessageSize = 6000000 <-- Cast as System.ServiceModel.NetTcpBinding to access other properties var listener = new WcfCommunicationListener <IPlatformAuthenticationService>( context, new PlatformAuthenticationService(), bindings, new EndpointAddress(serviceUri)); ServiceMetadataBehavior metaDataBehavior = new ServiceMetadataBehavior(); listener.ServiceHost.Description.Behaviors.Add(metaDataBehavior); Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding(); listener.ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, metaExchangeUri, new Uri(metaExchangeUri)); listener.ServiceHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); listener.ServiceHost.Description.Behaviors.Add(new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true }); return(listener); }
/// <summary> /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests. /// </summary> /// <returns>A collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { Binding binding = new BindingConfig().GetBindingWSHttp(); // set the proper way to expose the URI on cluster manager string host = this.Context.NodeContext.IPAddressOrFQDN; var endpointConfig = this.Context.CodePackageActivationContext.GetEndpoint("ServiceHttpEndPoint"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string nodeName = this.Context.NodeContext.NodeName; string servicename = this.Context.ServiceTypeName; string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}/{4}.svc", scheme, host, port, nodeName, servicename); WcfCommunicationListener <IPressContract> pressListener = new WcfCommunicationListener <IPressContract>(this.Context, this, binding, new EndpointAddress(uri)); // Check to see if the service host already has a ServiceMetadataBehavior, If not, add one if (pressListener.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>() == null) { ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; behavior.HttpGetUrl = new Uri(uri + "/mex/"); pressListener.ServiceHost.Description.Behaviors.Add(behavior); pressListener.ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), uri + "/mex/"); } ServiceInstanceListener listener = new ServiceInstanceListener(context => pressListener); return(new[] { listener }); }
private WcfCommunicationListener <IService> GetInstance(StatelessServiceContext context) { var host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("wcfEndpoint"); int port = endpointConfig.Port; string schema = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}", schema, host, port); var listener = new WcfCommunicationListener <IService>( wcfServiceObject: new Service(), serviceContext: context, listenerBinding: CreateDefaultHttpBinding(), address: new EndpointAddress(uri) ); ServiceMetadataBehavior smb = listener.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); // If not, add one if (smb == null) { smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri(uri); listener.ServiceHost.Description.Behaviors.Add(smb); } return(listener); }
/// <summary> /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests. /// </summary> /// <returns>A collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { Binding binding = new BindingConfig().GetBinding(); string host = this.Context.NodeContext.IPAddressOrFQDN; var endpointConfig = this.Context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string nodeName = this.Context.NodeContext.NodeName; string servicename = this.Context.ServiceTypeName; string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}/{4}.svc", "net." + scheme, host, port, nodeName, servicename); WcfCommunicationListener <IPresidentialService> pressListener = new WcfCommunicationListener <IPresidentialService>(this.Context, this, binding, new EndpointAddress(uri)); // Check to see if the service host already has a ServiceMetadataBehavior, If not, add one // For net.tcp need to find a way to expose metadata //if (pressListener.ServiceHost.Description.Behaviors.Find<ServiceMetadataBehavior>() == null) //{ // ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); // behavior.HttpGetEnabled = true; // need to figure it out how to bypass this for net.tcp // behavior.HttpGetUrl = new Uri(uri + "mex/"); // need to figure it out how to bypass this for net.tcp // pressListener.ServiceHost.Description.Behaviors.Add(behavior); // pressListener.ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), uri + "mex/"); //} ServiceInstanceListener listener = new ServiceInstanceListener(context => pressListener); return(new[] { listener }); }
private static ICommunicationListener CreateWcfTcpCommunicationListener <TStatelessService, TStatelessServiceImpl>(StatelessServiceContext context, string endpointName, TStatelessServiceImpl serviceImplementation, ILogger logger) where TStatelessServiceImpl : TStatelessService { ApplicationContext.Initialize(context); // TODO: Further parameterize string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint(endpointName); int port = endpointConfig.Port; var scheme = endpointConfig.UriScheme; var protocol = endpointConfig.Protocol; if (protocol != System.Fabric.Description.EndpointProtocol.Tcp) { // TODO: consider supporting http and https protocols along with certificates. throw new NotSupportedException("Only WCF over TCP via NetTcpBinding is currently supported."); } NetTcpBinding binding; try { binding = new NetTcpBinding("EnterprisePlatform"); } catch (KeyNotFoundException) { // no override entry was detected in the config - use defaults // Setting the security mode to Transport and credentialType to Basic' binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None; // binding.Security.Mode = SecurityMode.Message; // binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; } binding.Namespace = $"{context.CodePackageActivationContext.ApplicationTypeName}"; string componentName = Naming.Component <TStatelessService>(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}", scheme, host, port, componentName); var listener = new WcfCommunicationListener <TStatelessService>( serviceContext: context, wcfServiceObject: serviceImplementation, listenerBinding: binding, address: new EndpointAddress(uri) ); // TODO: Add when servicemodel.core is available // listener.ServiceHost.RunAsMicroservice(); if (logger != null) { // listener.ServiceHost.AddErrorHandler(ex => logger.LogError(ex, ex.Message)); } return(listener); }
private ICommunicationListener CreateDuplexListener(StatelessServiceContext context) { var listener = new WcfCommunicationListener <IDuplexContract>( wcfServiceObject: new WcfDuplexImplementation(), serviceContext: context, endpointResourceName: "WCFDuplexEndpoint", listenerBinding: WcfUtility.CreateTcpListenerBinding() ); return(listener); }
private ICommunicationListener CreateHiCommunicationListener(StatefulServiceContext context) { var listener = new WcfCommunicationListener <IHiContract>( wcfServiceObject: new Hi(), serviceContext: context, endpointResourceName: "HiEndpoint", listenerBinding: WcfUtility.CreateTcpListenerBinding() ); return(listener); }
private static ICommunicationListener CreateListenerIAdvancedCalc(StatelessServiceContext context) { var listener = new WcfCommunicationListener <IAdvancedCalc>( context, new AdvancedCalc(), GetWebBinding(), GetEndpointAddressIAdvancedCalc(context) ); AddWebBehavior(listener.ServiceHost); return(listener); }
protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners() { return(new[] { new ServiceReplicaListener((context) => { var listener = new WcfCommunicationListener <IScadaStorageService>( wcfServiceObject: new ScadaStorageServiceProvider(this.Context, this.StateManager), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), endpointResourceName: "ServiceEndpointStorage" ); return listener; }) }); }
/// <summary> /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests. /// </summary> /// <returns>A collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { return(new[] { new ServiceInstanceListener((context) => { var listener = new WcfCommunicationListener <IFEPServiceAsync>( wcfServiceObject: new FEPProvider(this.Context, AddCommand), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), endpointResourceName: "ServiceEndpointFep" // iz ServiceManifest.xml ); return listener; }) }); }
protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { return(new[] { new ServiceInstanceListener((context) => { var listener = new WcfCommunicationListener <ICEServiceAsync>( wcfServiceObject: new CEServiceProvider(this.UpdatePoints, this.Context), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), endpointResourceName: "ServiceEndpointCE" ); return listener; }) }); }
private ICommunicationListener CreateWcfCommunicationListener(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("WcfServiceEndpoint"); int port = endpointConfig.Port; var scheme = endpointConfig.Protocol.ToString(); var binding = new BasicHttpsBinding() { Namespace = "https://samplewcf.dev.com/" }; // Setting the security mode to Transport and credentialType to Basic' binding.Security.Mode = BasicHttpsSecurityMode.Transport; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/wcfservice", scheme, host, port); var listener = new WcfCommunicationListener <IWcfService>( serviceContext: context, wcfServiceObject: new WcfServiceImplementation(), listenerBinding: binding, address: new EndpointAddress(uri) ); listener.ServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNamePasswordValidator(); listener.ServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; // Adding the behaviour to generate flat WSDL without any WSDL imports foreach (var endpoint in listener.ServiceHost.Description.Endpoints) { endpoint.EndpointBehaviors.Add(new FlatWsdl()); } // Check to see if the service host already has a ServiceMetadataBehavior ServiceMetadataBehavior smb = listener.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); // If not, add one if (smb == null) { smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpsGetEnabled = true; smb.HttpsGetUrl = new Uri(uri); listener.ServiceHost.Description.Behaviors.Add(smb); } return(listener); }
private static ICommunicationListener CreateWcfWebCommunicationListener(StatefulServiceContext context) { var listener = new WcfCommunicationListener <ICalcLib>( context, new CalcLib(), GetWebBinding(), GetListenEndpointAddress(context) ); var endpoint = listener.ServiceHost.Description.Endpoints[0]; endpoint.EndpointBehaviors.Add(new WebHttpBehavior()); return(listener); }
private WcfCommunicationListener <ICalculation> GetInstance(StatelessServiceContext context) { var host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("wcfEndpoint"); int port = endpointConfig.Port; string schema = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}", schema, host, port); var listner = new WcfCommunicationListener <ICalculation>( wcfServiceObject: new CalculationService(), serviceContext: context, listenerBinding: CreateDefaultHttpBinding(), address: new EndpointAddress(uri) ); return(listner); }
private WcfCommunicationListener <T> CreateListenerOfType <T>(ServiceContext context, T serviceInstance, string rootDir) { var binding = new WebHttpBinding("webHttpBinding"); //defined in App.config var endpoint = context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); string host = context.NodeContext.IPAddressOrFQDN; var serviceUri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}/", endpoint.Protocol, host, endpoint.Port, rootDir); var address = new EndpointAddress(serviceUri); var listener = new WcfCommunicationListener <T>(context, serviceInstance, binding, address); //"ServiceEndpoint"); var endPoint = listener.ServiceHost.Description.Endpoints.Last(); endPoint.EndpointBehaviors.Add(new WebHttpBehavior()); return(listener); }
private ICommunicationListener CreateWCFListenerForAdd(StatelessServiceContext context) { var bindings = WcfUtility.CreateTcpListenerBinding(); var listener = new WcfCommunicationListener <IAdd>( context, new AddService(context), bindings, new EndpointAddress("net.tcp://localhost:8085/Services/Tests1")); ServiceMetadataBehavior metaDataBehavior = new ServiceMetadataBehavior(); listener.ServiceHost.Description.Behaviors.Add(metaDataBehavior); Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding(); listener.ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "net.tcp://localhost:8086/Services/Tests1/mex", new Uri("net.tcp://localhost:8086/Services/Tests1/mex")); return(listener); }
protected override ICommunicationListener CreateCommunicationListener() { WcfCommunicationListener communicationListener = new WcfCommunicationListener(typeof(ICalculator), this) { // // The name of the endpoint configured in the ServiceManifest under the Endpoints section // which identifies the endpoint that the wcf servicehost should listen on. // EndpointResourceName = "ServiceEndpoint", // // Populate the binding information that you want the service to use. // Binding = this.CreateListenBinding() }; return(communicationListener); }
protected override ICommunicationListener CreateCommunicationListener() { WcfCommunicationListener communicationListener = new WcfCommunicationListener(typeof(ICalculator), this) { // // The name of the endpoint configured in the ServiceManifest under the Endpoints section // which identifies the endpoint that the wcf servicehost should listen on. // EndpointResourceName = "ServiceEndpoint", // // Populate the binding information that you want the service to use. // Binding = this.CreateListenBinding() }; return communicationListener; }
private static ICommunicationListener CreateRestListener(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("CalculatorEndpoint"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/", scheme, host, port); var listener = new WcfCommunicationListener <ICalculatorService>( serviceContext: context, wcfServiceObject: new WcfCalculatorService(), listenerBinding: new WebHttpBinding(WebHttpSecurityMode.None), address: new EndpointAddress(uri) ); var ep = listener.ServiceHost.Description.Endpoints.Last(); ep.Behaviors.Add(new WebHttpBehavior()); return(listener); }
protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { return(new[] { new ServiceInstanceListener((context) => { string host = host = context.NodeContext.IPAddressOrFQDN; EndpointResourceDescription endpointConfig = context.CodePackageActivationContext.GetEndpoint("ServiceEndPointM"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/CEDynamicsService", "net.tcp", host, port); var listener = new WcfCommunicationListener <IModelUpdateAsync>( wcfServiceObject: new CEModelProvider(this.Context), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), address: new EndpointAddress(uri) ); return listener; }, "CEModelProvider"), new ServiceInstanceListener((context) => { string host = host = context.NodeContext.IPAddressOrFQDN; EndpointResourceDescription endpointConfig = context.CodePackageActivationContext.GetEndpoint("ServiceEndPointTR"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/CEDynamicsService", "net.tcp", host, port); var listener = new WcfCommunicationListener <ITransactionStepsAsync>( wcfServiceObject: new CETransactionProvider(this.Context), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), address: new EndpointAddress(uri) ); return listener; }, "CETransactionProvider") }); }
/// <summary> /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests. /// </summary> /// <returns>A collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { return(new[] { new ServiceInstanceListener(context => { var Listener = new WcfCommunicationListener <ICalculatorService>(context, new CalculatorService(), new NetTcpBinding(), "ServiceEndpoint"); Listener.ServiceHost.Description.Endpoints.Last().EndpointBehaviors.Add(new MyEndpointBehavior()); return Listener; }, "NetTcp"), new ServiceInstanceListener(context => { var Listener = new WcfCommunicationListener <ICalculatorService>(context, new CalculatorService(), new BasicHttpBinding(), "HttpServiceEndpoint"); Listener.ServiceHost.Description.Endpoints.Last().EndpointBehaviors.Add(new MyEndpointBehavior()); return Listener; }, "Http") }); }
private ICommunicationListener CreateGatewayListener(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("GatewayHelloEndpoint"); int port = endpointConfig.Port; var scheme = endpointConfig.UriScheme.ToString(); var pathSufix = endpointConfig.PathSuffix.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/Gateway/{3}", scheme, host, port, pathSufix); var listener = new WcfCommunicationListener <IHelloContract>( wcfServiceObject: new GatewayServiceImplementation(), serviceContext: context, listenerBinding: WcfUtility.CreateTcpListenerBinding(), address: new EndpointAddress(uri) ); return(listener); }
/// <summary> /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests. /// </summary> /// <returns>A collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { ServiceEventSource.Current.Message("Open WCF Web Frontend"); yield return(new ServiceInstanceListener(context => { string host = context.NodeContext.IPAddressOrFQDN; var endpointConfig = context.CodePackageActivationContext.GetEndpoint("WebFrontendServiceEndpoint"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/", scheme, host, port); var listener = new WcfCommunicationListener <IWebFrontend>( serviceContext: context, wcfServiceObject: new WebFrontendService(context), listenerBinding: new WebHttpBinding(WebHttpSecurityMode.None), address: new EndpointAddress(uri) ); var ep = listener.ServiceHost.Description.Endpoints.Last(); ep.Behaviors.Add(new WebHttpBehavior()); return listener; })); }
protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners() { var listeners = new[] { new ServiceReplicaListener((context) => { string host = host = context.NodeContext.IPAddressOrFQDN; EndpointResourceDescription endpointConfig = context.CodePackageActivationContext.GetEndpoint("ServiceEndpointP"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/NetworkModelServiceSF", "net.tcp", host, port); var listener = new WcfCommunicationListener <INetworkModelService>( wcfServiceObject: new NetworkModelServiceProvider(this.StateManager, this.Context, ApplyDelta, GetValue, GetValues), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), address: new EndpointAddress(uri) ); return(listener); }, "NetowrkModelServiceSF"), new ServiceReplicaListener((context) => { string host = host = context.NodeContext.IPAddressOrFQDN; EndpointResourceDescription endpointConfig = context.CodePackageActivationContext.GetEndpoint("ServiceEndpointTR"); int port = endpointConfig.Port; string scheme = endpointConfig.Protocol.ToString(); string uri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/NetworkModelServiceSF", "net.tcp", host, port); var listener = new WcfCommunicationListener <ITransactionStepsAsync>( wcfServiceObject: new NetworkModelServiceTransactionProvider(this.Context, Prepare, Commit, Rollback), serviceContext: context, listenerBinding: new NetTcpBinding(SecurityMode.None), address: new EndpointAddress(uri) ); return(listener); }, "NetowrkModelServiceSFTransaction") }; return(listeners); }
private ICommunicationListener CreateWcfHiCommunicationListener(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; // ServiceManifest fajl var endpointConfig = context.CodePackageActivationContext.GetEndpoint("NMTransactionServiceEndpoint"); int port = endpointConfig.Port; var scheme = endpointConfig.Protocol.ToString(); var pathSufix = endpointConfig.PathSuffix.ToString(); var binding = new NetTcpBinding(); //var binding = WcfUtility.CreateTcpListenerBinding(); string uri = string.Format(CultureInfo.InvariantCulture, "net.{0}://{1}:{2}/ITransaction/{3}", scheme, host, port, pathSufix); NetworkModelTransactionService networkModelTransactionService = new NetworkModelTransactionService(); var listener = new WcfCommunicationListener <ITransaction>( serviceContext: context, wcfServiceObject: networkModelTransactionService, listenerBinding: binding, address: new EndpointAddress(uri) ); return(listener); }
private WcfCommunicationListener <T> CreateSoapListener <T>(ServiceContext context, T serviceInstance, string rootDir) { var binding = new BasicHttpBinding("basicHttpBinding"); var endpoint = context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); string host = context.NodeContext.IPAddressOrFQDN; var serviceUri = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}/", endpoint.Protocol, host, endpoint.Port, "wsdl/" + rootDir); var address = new EndpointAddress(serviceUri); var listener = new WcfCommunicationListener <T>(context, serviceInstance, binding, address); //"ServiceEndpoint"); ServiceMetadataBehavior smb = listener.ServiceHost.Description.Behaviors.Find <ServiceMetadataBehavior>(); // If not, add one if (smb == null) { smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Default; smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri(serviceUri); listener.ServiceHost.Description.Behaviors.Add(smb); } return(listener); }
private ICommunicationListener CreateWcfCommunicationListenerTransaction(StatelessServiceContext context) { string host = context.NodeContext.IPAddressOrFQDN; // ServiceManifest fajl var endpointConfig = context.CodePackageActivationContext.GetEndpoint("DMSTransactionService"); int port = endpointConfig.Port; var scheme = endpointConfig.Protocol.ToString(); var pathSufix = endpointConfig.PathSuffix.ToString(); var binding = new NetTcpBinding(); //var binding = WcfUtility.CreateTcpListenerBinding(); string uri = string.Format(CultureInfo.InvariantCulture, "net.{0}://{1}:{2}/ITransaction", scheme, host, port); var listener = new WcfCommunicationListener <ITransaction>( serviceContext: context, wcfServiceObject: new DMSTransactionService(), listenerBinding: BindingForTCP.CreateCustomNetTcp(), // address: new EndpointAddress(uri) endpointResourceName: "DMSTransactionService" ); return(listener); }