void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingParameters"); } SecurityCredentialsManager manager = bindingParameters.Find <SecurityCredentialsManager>(); if (manager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleSecurityCredentialsManagersInChannelBindingParameters", new object[] { manager }))); } bindingParameters.Add(this); }
protected override void InitializeRuntime() { MessageFilter contractFilter = this.listenerFilter; int filterPriority = 10; Type[] endpointChannelTypes = new Type[] { typeof(IReplyChannel), typeof(IDuplexChannel), typeof(IReplySessionChannel), typeof(IDuplexSessionChannel) }; IChannelListener listener = null; BindingParameterCollection parameters = new BindingParameterCollection(this.channelBuilder.BindingParameters); Binding binding = this.channelBuilder.Binding; binding.ReceiveTimeout = this.authenticator.NegotiationTimeout; parameters.Add(new ChannelDemuxerFilter(contractFilter, filterPriority)); DispatcherBuilder.MaybeCreateListener(true, endpointChannelTypes, binding, parameters, this.listenUri, "", ListenUriMode.Explicit, this.ServiceThrottle, out listener); if (listener == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotCreateTwoWayListenerForNegotiation))); } ChannelDispatcher channelDispatcher = new ChannelDispatcher(listener, null, binding); channelDispatcher.MessageVersion = binding.MessageVersion; channelDispatcher.ManualAddressing = true; channelDispatcher.ServiceThrottle = new ServiceThrottle(this); channelDispatcher.ServiceThrottle.MaxConcurrentCalls = this.authenticator.MaximumConcurrentNegotiations; channelDispatcher.ServiceThrottle.MaxConcurrentSessions = this.authenticator.MaximumConcurrentNegotiations; EndpointDispatcher endpointDispatcher = new EndpointDispatcher(new EndpointAddress(this.listenUri), "SecurityNegotiationContract", NamingHelper.DefaultNamespace, true); endpointDispatcher.DispatchRuntime.SingletonInstanceContext = new InstanceContext(null, this.authenticator, false); endpointDispatcher.DispatchRuntime.ConcurrencyMode = ConcurrencyMode.Multiple; endpointDispatcher.AddressFilter = new MatchAllMessageFilter(); endpointDispatcher.ContractFilter = contractFilter; endpointDispatcher.FilterPriority = filterPriority; endpointDispatcher.DispatchRuntime.PrincipalPermissionMode = PrincipalPermissionMode.None; endpointDispatcher.DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(endpointDispatcher.DispatchRuntime); endpointDispatcher.DispatchRuntime.SynchronizationContext = null; DispatchOperation operation = new DispatchOperation(endpointDispatcher.DispatchRuntime, "*", MessageHeaders.WildcardAction, MessageHeaders.WildcardAction); operation.Formatter = new MessageOperationFormatter(); operation.Invoker = new NegotiationSyncInvoker(this.authenticator); endpointDispatcher.DispatchRuntime.UnhandledDispatchOperation = operation; channelDispatcher.Endpoints.Add(endpointDispatcher); this.ChannelDispatchers.Add(channelDispatcher); }
public static void Snippet20() { // <Snippet20> CustomBinding binding = new CustomBinding(); HttpTransportBindingElement element = new HttpTransportBindingElement(); BindingParameterCollection parameters = new BindingParameterCollection(); parameters.Add(new ServiceCredentials()); Uri baseAddress = new Uri("http://localhost:8000/ChannelApp"); String relAddress = "http://localhost:8000/ChannelApp/service"; BindingContext context = new BindingContext(binding, parameters, baseAddress, relAddress, ListenUriMode.Explicit); ServiceCredentials serviceCredentials = element.GetProperty <ServiceCredentials>(context); // </Snippet20> }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters)); } // throw if bindingParameters already has a SecurityCredentialsManager SecurityCredentialsManager otherCredentialsManager = parameters.Find <SecurityCredentialsManager>(); if (otherCredentialsManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MultipleSecurityCredentialsManagersInServiceBindingParameters, otherCredentialsManager))); } parameters.Add(this); }
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingParameters"); } // throw if bindingParameters already has a SecurityCredentialsManager SecurityCredentialsManager otherCredentialsManager = bindingParameters.Find <SecurityCredentialsManager>(); if (otherCredentialsManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MultipleSecurityCredentialsManagersInChannelBindingParameters, otherCredentialsManager))); } bindingParameters.Add(this); }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } if (this.serviceAuthenticationManager != null) { // throw if bindingParameters already has a AuthenticationManager ServiceAuthenticationManager otherAuthenticationManager = parameters.Find <ServiceAuthenticationManager>(); if (otherAuthenticationManager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleAuthenticationManagersInServiceBindingParameters, otherAuthenticationManager))); } parameters.Add(this.serviceAuthenticationManager); } if (this.authenticationSchemes != AuthenticationSchemes.None) { // throw if bindingParameters already has an AuthenticationSchemes AuthenticationSchemesBindingParameter otherAuthenticationSchemesBindingParameter = parameters.Find <AuthenticationSchemesBindingParameter>(); if (otherAuthenticationSchemesBindingParameter != null) { if (otherAuthenticationSchemesBindingParameter.AuthenticationSchemes != authenticationSchemes) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleAuthenticationSchemesInServiceBindingParameters, otherAuthenticationSchemesBindingParameter.AuthenticationSchemes))); } } else { parameters.Add(new AuthenticationSchemesBindingParameter(this.authenticationSchemes)); } } }
internal override void AddMetadataBindingParameters(Uri listenUri, KeyedByTypeCollection <IServiceBehavior> serviceBehaviors, BindingParameterCollection bindingParameters) { if (serviceBehaviors.Find <HostedBindingBehavior>() != null) { bindingParameters.Add(new HostedMetadataBindingParameter()); } VirtualPathExtension virtualPathExtension = bindingParameters.Find <VirtualPathExtension>(); if (virtualPathExtension != null) { AuthenticationSchemes hostSupportedAuthenticationSchemes = AspNetEnvironment.Current.GetAuthenticationSchemes(listenUri); if (hostSupportedAuthenticationSchemes != AuthenticationSchemes.None) { if (bindingParameters.Find <AuthenticationSchemesBindingParameter>() == null) { bindingParameters.Add(new AuthenticationSchemesBindingParameter(hostSupportedAuthenticationSchemes)); } } } base.AddMetadataBindingParameters(listenUri, serviceBehaviors, bindingParameters); }
public void GetInnerPropertyIsNothingToDoWithParameters() { BindingParameterCollection pl = new BindingParameterCollection(); pl.Add(new ClientCredentials()); BindingContext ctx = new BindingContext(new CustomBinding(), pl); Assert.IsNull(ctx.GetInnerProperty <ClientCredentials> ()); CustomBinding binding = new CustomBinding(new HttpTransportBindingElement()); ctx = new BindingContext(binding, pl); Assert.IsNull(ctx.GetInnerProperty <ClientCredentials> ()); }
void System.ServiceModel.Description.IEndpointBehavior.AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { NameSettings nameSetting = new NameSettings() { DisplayName = this.displayName }; nameSetting.ServiceSettings.Discovery = this.discoveryType; nameSetting.ServiceSettings.RelayClientAuthenticationType = (this.allowUnauthenticatedAccess ? RelayClientAuthenticationType.None : RelayClientAuthenticationType.RelayAccessToken); nameSetting.ServiceSettings.TransportProtection = (this.transportProtectionEnabled ? RelayTransportProtectionMode.EndToEnd : RelayTransportProtectionMode.None); if (this.PreserveRawHttp.HasValue) { nameSetting.ServiceSettings.PreserveRawHttp = this.PreserveRawHttp.Value; } bindingParameters.Add(nameSetting); }
void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } System.ServiceModel.ServiceAuthenticationManager manager = parameters.Find <System.ServiceModel.ServiceAuthenticationManager>(); if (manager != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleAuthenticationManagersInServiceBindingParameters", new object[] { manager }))); } if (this.serviceAuthenticationManager != null) { parameters.Add(this.serviceAuthenticationManager); } }
protected override void InitializeRuntime() { MessageFilter listenerFilter = this.listenerFilter; int priority = 10; System.Type[] supportedChannels = new System.Type[] { typeof(IReplyChannel), typeof(IDuplexChannel), typeof(IReplySessionChannel), typeof(IDuplexSessionChannel) }; IChannelListener result = null; BindingParameterCollection parameters = new BindingParameterCollection(this.channelBuilder.BindingParameters); Binding binding = this.channelBuilder.Binding; binding.ReceiveTimeout = this.authenticator.NegotiationTimeout; parameters.Add(new ChannelDemuxerFilter(listenerFilter, priority)); DispatcherBuilder.MaybeCreateListener(true, supportedChannels, binding, parameters, this.listenUri, "", ListenUriMode.Explicit, base.ServiceThrottle, out result); if (result == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotCreateTwoWayListenerForNegotiation"))); } ChannelDispatcher item = new ChannelDispatcher(result, null, binding) { MessageVersion = binding.MessageVersion, ManualAddressing = true, ServiceThrottle = new ServiceThrottle(this) }; item.ServiceThrottle.MaxConcurrentCalls = this.authenticator.MaximumConcurrentNegotiations; item.ServiceThrottle.MaxConcurrentSessions = this.authenticator.MaximumConcurrentNegotiations; EndpointDispatcher dispatcher2 = new EndpointDispatcher(new EndpointAddress(this.listenUri, new AddressHeader[0]), "SecurityNegotiationContract", "http://tempuri.org/", true) { DispatchRuntime = { SingletonInstanceContext = new InstanceContext(null, this.authenticator, false), ConcurrencyMode = ConcurrencyMode.Multiple }, AddressFilter = new MatchAllMessageFilter(), ContractFilter = listenerFilter, FilterPriority = priority }; dispatcher2.DispatchRuntime.PrincipalPermissionMode = PrincipalPermissionMode.None; dispatcher2.DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(dispatcher2.DispatchRuntime); dispatcher2.DispatchRuntime.SynchronizationContext = null; DispatchOperation operation = new DispatchOperation(dispatcher2.DispatchRuntime, "*", "*", "*") { Formatter = new MessageOperationFormatter(), Invoker = new NegotiationSyncInvoker <T>(this.authenticator) }; dispatcher2.DispatchRuntime.UnhandledDispatchOperation = operation; item.Endpoints.Add(dispatcher2); base.ChannelDispatchers.Add(item); }
StreamSecurityUpgradeProvider CreateClientProvider(params object [] parameters) { SslStreamSecurityBindingElement bel = new SslStreamSecurityBindingElement(); BindingParameterCollection pl = new BindingParameterCollection(); foreach (object o in parameters) { pl.Add(o); } BindingContext ctx = new BindingContext( new CustomBinding(new HttpTransportBindingElement()), pl); return(bel.BuildClientStreamUpgradeProvider(ctx) as StreamSecurityUpgradeProvider); }
protected override void InitializeRuntime() { BindingParameterCollection bpc = new BindingParameterCollection(); VirtualPathExtension virtualPathExtension = this.Extensions.Find <VirtualPathExtension>(); if (virtualPathExtension != null) { bpc.Add(virtualPathExtension); } BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); IChannelListener <IReplyChannel> listener = basicHttpBinding.BuildChannelListener <IReplyChannel>(interestedUri, bpc); CustomChannelDispatcher channelDispatcher = new CustomChannelDispatcher(serviceManager, listener); this.ChannelDispatchers.Add(channelDispatcher); }
public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { ChunkingBindingParameter chunkingBindingParameter = parameters.Find <ChunkingBindingParameter>(); if (chunkingBindingParameter == null) { chunkingBindingParameter = new ChunkingBindingParameter(); parameters.Add(chunkingBindingParameter); } if ((this.appliesTo & ChunkingAppliesTo.InMessage) == ChunkingAppliesTo.InMessage) { chunkingBindingParameter.AddAction(description.Messages[0].Action); } if (!description.IsOneWay && (this.appliesTo & ChunkingAppliesTo.OutMessage) == ChunkingAppliesTo.OutMessage) { chunkingBindingParameter.AddAction(description.Messages[1].Action); } }
BindingParameterCollection CreateBindingParameters() { BindingParameterCollection pl = new BindingParameterCollection(); ContractDescription cd = Endpoint.Contract; #if !NET_2_1 pl.Add(ChannelProtectionRequirements.CreateFromContract(cd)); foreach (IEndpointBehavior behavior in Endpoint.Behaviors) { behavior.AddBindingParameters(Endpoint, pl); } #endif return(pl); }
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { var requirements = new ChannelProtectionRequirements(); var signatureProtectionSpecification = new MessagePartSpecification(_protectionLevel != ProtectionLevel.None); requirements.IncomingSignatureParts.AddParts(signatureProtectionSpecification, "*"); requirements.OutgoingSignatureParts.AddParts(signatureProtectionSpecification, "*"); var encryptionProtectionSpecification = new MessagePartSpecification(_protectionLevel == ProtectionLevel.EncryptAndSign); requirements.IncomingEncryptionParts.AddParts(encryptionProtectionSpecification, "*"); requirements.OutgoingEncryptionParts.AddParts(encryptionProtectionSpecification, "*"); bindingParameters.Remove <ChannelProtectionRequirements>(); bindingParameters.Add(requirements); endpoint.Contract.ProtectionLevel = _protectionLevel; }
//This method generates the BindingParameterCollection in the same way it is created during DispatcherBuilder.InitializeServiceHost internal static BindingParameterCollection GetBindingParameters(ServiceHostBase serviceHost, Collection <ServiceEndpoint> endpoints) { BindingParameterCollection parameters = new BindingParameterCollection(); parameters.Add(new ThreadSafeMessageFilterTable <EndpointAddress>()); foreach (IServiceBehavior behavior in serviceHost.Description.Behaviors) { behavior.AddBindingParameters(serviceHost.Description, serviceHost, endpoints, parameters); } foreach (ServiceEndpoint endpoint in endpoints) { AddBindingParametersForSecurityContractInformation(endpoint, parameters); AddBindingParameters(endpoint, parameters); } return(parameters); }
private void AddBindingParameters(BindingParameterCollection commonParams, ServiceEndpoint endPoint) { commonParams.Add(ChannelProtectionRequirements.CreateFromContract(endPoint.Contract)); foreach (IContractBehavior b in endPoint.Contract.Behaviors) { b.AddBindingParameters(endPoint.Contract, endPoint, commonParams); } foreach (IEndpointBehavior b in endPoint.Behaviors) { b.AddBindingParameters(endPoint, commonParams); } foreach (OperationDescription operation in endPoint.Contract.Operations) { foreach (IOperationBehavior b in operation.Behaviors) { b.AddBindingParameters(operation, commonParams); } } }
public static void AddBindingParametersForSecurityContractInformation(ServiceEndpoint endpoint, BindingParameterCollection parameters) { // get Contract info security needs, and put in BindingParameterCollection ISecurityCapabilities isc = null; BindingElementCollection elements = endpoint.Binding.CreateBindingElements(); for (int i = 0; i < elements.Count; ++i) { if (!(elements[i] is ITransportTokenAssertionProvider)) { ISecurityCapabilities tmp = elements[i].GetIndividualProperty <ISecurityCapabilities>(); if (tmp != null) { isc = tmp; break; } } } if (isc != null) { // ensure existence of binding parameter ChannelProtectionRequirements requirements = parameters.Find <ChannelProtectionRequirements>(); if (requirements == null) { requirements = new ChannelProtectionRequirements(); parameters.Add(requirements); } MessageEncodingBindingElement encoding = elements.Find <MessageEncodingBindingElement>(); // use endpoint.Binding.Version if (encoding != null && encoding.MessageVersion.Addressing == AddressingVersion.None) { // This binding does not support response actions, so... requirements.Add(ChannelProtectionRequirements.CreateFromContractAndUnionResponseProtectionRequirements(endpoint.Contract, isc)); } else { requirements.Add(ChannelProtectionRequirements.CreateFromContract(endpoint.Contract, isc)); } } }
private BindingContext CreateInnerListenerBindingContext(BindingContext context) { BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = ClientMessageUtility.CreateInnerEncodingBindingElement(context); NameSettings nameSetting = context.BindingParameters.Find <NameSettings>(); TcpRelayTransportBindingElement tcpRelayTransportBindingElement = new TcpRelayTransportBindingElement(this.RelayClientAuthenticationType) { ManualAddressing = base.ManualAddressing, HostNameComparisonMode = this.HostNameComparisonMode, MaxBufferPoolSize = this.MaxBufferPoolSize, MaxBufferSize = this.MaxBufferSize, MaxReceivedMessageSize = this.MaxReceivedMessageSize, TransferMode = System.ServiceModel.TransferMode.Streamed, TransportProtectionEnabled = nameSetting.ServiceSettings.TransportProtection != RelayTransportProtectionMode.None }; tcpRelayTransportBindingElement.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = 100; tcpRelayTransportBindingElement.IsDynamic = nameSetting.ServiceSettings.IsDynamic; BindingElement[] bindingElementArray = new BindingElement[] { binaryMessageEncodingBindingElement, tcpRelayTransportBindingElement }; CustomBinding customBinding = new CustomBinding(bindingElementArray) { CloseTimeout = context.Binding.CloseTimeout, Name = context.Binding.Name, Namespace = context.Binding.Namespace, OpenTimeout = context.Binding.OpenTimeout, ReceiveTimeout = context.Binding.ReceiveTimeout, SendTimeout = context.Binding.SendTimeout }; BindingParameterCollection bindingParameterCollection = new BindingParameterCollection(); foreach (object bindingParameter in context.BindingParameters) { if (bindingParameter is MessageEncodingBindingElement) { continue; } bindingParameterCollection.Add(bindingParameter); } Uri sbUri = RelayedHttpUtility.ConvertToSbUri(context.ListenUriBaseAddress); return(new BindingContext(customBinding, bindingParameterCollection, sbUri, context.ListenUriRelativeAddress, context.ListenUriMode)); }
/// <summary> /// Adds the requirement telling WCF to encrypt the body of RM messages /// </summary> private void AddProtectionRequirements(BindingParameterCollection bindingParameters) { logging.WCFLogger.Write(System.Diagnostics.TraceEventType.Start, "Custom header signing behavior adding protection requirements"); // Get the protection requirements for the binding ChannelProtectionRequirements cpr = bindingParameters.Find <ChannelProtectionRequirements>(); // If there were no requirements since before, create them if (cpr == null) { cpr = new ChannelProtectionRequirements(); bindingParameters.Add(cpr); } // Select the headers to be affected by this behavior MessagePartSpecification headerMessagePart = new MessagePartSpecification(_headers.ToArray()); headerMessagePart.MakeReadOnly(); ChannelProtectionRequirements newCpr = new ChannelProtectionRequirements(); // Specify each header to be signed foreach (string action in actionsToWhichThisBehaviorApplies) { newCpr.IncomingSignatureParts.AddParts(headerMessagePart, action); newCpr.OutgoingSignatureParts.AddParts(headerMessagePart, action); } newCpr.MakeReadOnly(); cpr.Add(newCpr); // Tracing foreach (XmlQualifiedName name in _headers) { logging.WCFLogger.Write(System.Diagnostics.TraceEventType.Information, "Header '" + name + "' added for signing"); } logging.WCFLogger.Write(System.Diagnostics.TraceEventType.Stop, "Custom header signing behavior finished adding protection requirements"); }
public void SendRequestWithSignatureMessagePart() { CustomBinding b = CreateBinding(); ChannelProtectionRequirements cp = new ChannelProtectionRequirements(); cp.IncomingSignatureParts.AddParts(new MessagePartSpecification(true), "myAction"); cp.IncomingEncryptionParts.AddParts(new MessagePartSpecification(true), "myAction"); BindingParameterCollection parameters = new BindingParameterCollection(); parameters.Add(cp); IChannelFactory <IRequestChannel> f = b.BuildChannelFactory <IRequestChannel> (parameters); f.Open(); IRequestChannel ch = f.CreateChannel(CreateX509EndpointAddress("stream:dummy")); ch.Open(); ch.Request(Message.CreateMessage(b.MessageVersion, "myAction")); }
private BindingContext CreateInnerChannelBindingContext(BindingContext context) { HttpTransportBindingElement httpTransportBindingElement = this.CreateInnerChannelBindingElement(); this.InitializeInnerChannelBindingElement(httpTransportBindingElement); BindingElement[] bindingElementArray = new BindingElement[] { httpTransportBindingElement }; CustomBinding customBinding = new CustomBinding(bindingElementArray) { CloseTimeout = context.Binding.CloseTimeout, Name = context.Binding.Name, Namespace = context.Binding.Namespace, OpenTimeout = context.Binding.OpenTimeout, ReceiveTimeout = context.Binding.ReceiveTimeout, SendTimeout = context.Binding.SendTimeout }; BindingParameterCollection bindingParameterCollection = new BindingParameterCollection(); foreach (object bindingParameter in context.BindingParameters) { bindingParameterCollection.Add(bindingParameter); } return(new BindingContext(customBinding, bindingParameterCollection, context.ListenUriBaseAddress, context.ListenUriRelativeAddress, context.ListenUriMode)); }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters)); } bool shouldAddBehavior = true; foreach (var param in parameters) { if (param is ServiceHealthBehaviorBase) { shouldAddBehavior = false; break; } } if (shouldAddBehavior) { parameters.Add(this); } }
public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters) { Console.WriteLine("IOperationBehavior - AddBindingParameters " + _host.ChannelDispatchers.Count); _state.CurrentStage += ", IOperationBehavior.AddBindingParameters"; bindingParameters.Add(this); }
public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { Console.WriteLine("Contract - AddBindingParameters " + _host.ChannelDispatchers.Count); _state.CurrentStage += ", IContractBehavior.AddBindingParameters"; bindingParameters.Add(this); }
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, global::System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { _state.CurrentStage += ", IServiceBehavior.AddBindingParameters"; bindingParameters.Add(this); }
internal virtual void AddMetadataBindingParameters(Uri listenUri, KeyedByTypeCollection <IServiceBehavior> serviceBehaviors, BindingParameterCollection bindingParameters) { bindingParameters.Add(new ServiceMetadataExtension.MetadataBindingParameter()); }
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { bindingParameters.Add(new Func <HttpClientHandler, HttpMessageHandler>(x => new CustomDelegatingHandler(x))); }
/// <summary> /// This factory class creates three different kinds of client. This method gathers the code of client creation /// and adds the retry logic. The retry can avoid transient connection error especially when connect to Azure. /// </summary> /// <param name="clientType">the type of the client</param> /// <returns>the client</returns> private ICommunicationObject CreateClientWithRetry(ClientType clientType) { ICommunicationObject client = null; Exception exception = null; try { exception = null; switch (clientType) { case ClientType.SendRequest: if (this.brokerClientFactory == null) { ClientCredentials clientCredentials = new ClientCredentials(); clientCredentials.UserName.UserName = this.info.Username; clientCredentials.UserName.Password = this.info.InternalPassword; BindingParameterCollection bindingParams = new BindingParameterCollection(); bindingParams.Add(clientCredentials); this.brokerClientFactory = this.binding.BuildChannelFactory <IRequestChannel>(bindingParams); this.brokerClientFactory.Open(); } client = this.brokerClientFactory.CreateChannel(GenerateEndpointAddress(this.info.BrokerEpr, this.scheme, this.info.Secure, this.info.IsAadOrLocalUser)); break; case ClientType.Controller: BrokerControllerClient controllerClient = new BrokerControllerClient( this.binding, GenerateEndpointAddress(this.info.ControllerEpr, this.scheme, this.info.Secure, this.info.IsAadOrLocalUser)); controllerClient.ClientCredentials.UserName.UserName = this.info.Username; controllerClient.ClientCredentials.UserName.Password = this.info.InternalPassword; client = controllerClient; break; default: throw new NotSupportedException(); } client.Open(); } catch (Exception e) { if (this.brokerClientFactory != null) { try { this.brokerClientFactory.Abort(); this.brokerClientFactory = null; } catch { // abandon the factory, swallow the exception } } if (client != null) { try { client.Abort(); client = null; } catch { // abandon the channel, swallow the exception } } exception = e; } if (exception != null) { throw exception; } return(client); }