public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime) { var behavior = dispatchRuntime.ChannelDispatcher.Host.Description.FindBehavior <WebAuthenticationConfigurationBehavior, WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior); if (behavior == null) { behavior = contractDescription.FindBehavior <WebAuthenticationConfigurationBehavior, WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior); } if (behavior == null) { throw new ServiceAuthenticationConfigurationMissingException(); } foreach (var endpointDispatcher in dispatchRuntime.ChannelDispatcher.Endpoints) { endpointDispatcher.DispatchRuntime.MessageInspectors.Add( new ServiceAuthenticationInspector( behavior.ThrowIfNull().AuthenticationHandler, behavior.UsernamePasswordValidatorType, behavior.RequireSecureTransport, behavior.Source)); } }