private Binding CreateBinding() { NetTcpBinding binding = new NetTcpBinding(); WCFHelper.ApplyWCFBindingLimits( binding, cm.Value.ClientServiceMaxSizeInBytes, cm.Value.ClientServiceTimeoutInSecs); binding.Security.Mode = SecurityMode.None; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; return(binding); }
protected override void ApplyConfiguration() { if (cm != null) { // visual studio debug hack START Uri[] arlBA = new Uri[this.BaseAddresses.Count]; this.BaseAddresses.CopyTo(arlBA, 0); ServiceHost shDummy = new ServiceHost(this.Description.ServiceType, arlBA); foreach (IServiceBehavior o in shDummy.Description.Behaviors) { if (o.GetType().ToString().Equals("Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior")) { this.Description.Behaviors.Add(o); break; } } // visual studio debug hack END ServiceDebugBehavior debug = new ServiceDebugBehavior(); debug.IncludeExceptionDetailInFaults = true; this.Description.Behaviors.Add(debug); ServiceThrottlingBehavior throttling = new ServiceThrottlingBehavior(); throttling.MaxConcurrentCalls = cm.Value.ClientServiceMaxConcurrentCalls; throttling.MaxConcurrentInstances = cm.Value.ClientServiceMaxConcurrentInstances; throttling.MaxConcurrentSessions = cm.Value.ClientServiceMaxConcurrentSessions; this.Description.Behaviors.Add(throttling); Binding binding = CreateBinding(); ServiceEndpoint ep = this.AddServiceEndpoint(typeof(IRemoteSideCommunicationContract), binding, String.Empty); EndpointAddress epa = new EndpointAddress(ep.Address.Uri, EndpointIdentity.CreateDnsIdentity("localhost"), ep.Address.Headers); ep.Address = epa; WCFHelper.ApplyWCFEndpointLimits(ep, cm.Value.ClientServiceMaxItemsInObjectGraph); ServiceMetadataBehavior mb = new ServiceMetadataBehavior(); this.Description.Behaviors.Add(mb); ServiceBehaviorAttribute sba = (ServiceBehaviorAttribute)(from a in this.Description.Behaviors where a.GetType() == typeof(ServiceBehaviorAttribute) select a).Single(); sba.InstanceContextMode = InstanceContextMode.Single; sba.ConcurrencyMode = ConcurrencyMode.Multiple; sba.UseSynchronizationContext = false; } }
public IRemoteSide CreateInstance() { IRemoteSide ret = null; // init binding var binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; var cm = diContainer.GetLazyBoundInstance <IWCFConfigManager>().Value; WCFHelper.ApplyWCFBindingLimits( binding, cm.ClientServiceMaxSizeInBytes, cm.ClientServiceTimeoutInSecs); // init endpoint address var endpointAddress = new EndpointAddress(cm.ClientServiceAddress); // create context var clientServiceInstance = diContainer.GetLazyBoundInstance <IRemoteSideCommunicationHandler>().Value; var instanceContext = new InstanceContext((IRemoteSideCommunicationContract)clientServiceInstance); // create client var cscc = new WCFServiceClient(instanceContext, binding, endpointAddress); clientServiceInstance.AssignRemoteSide(cscc); // init client WCFHelper.ApplyWCFEndpointLimits(cscc.Endpoint, cm.ClientServiceMaxItemsInObjectGraph); ret = cscc; return(ret); }