Мне просто нужно было решить ту же задачу.Это сработало для меня (для http).
var security = SecurityBindingElement.CreateSspiNegotiationBindingElement();
security.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;
security.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
security.IncludeTimestamp = true;
security.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
security.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
security.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
security.LocalClientSettings.CacheCookies = true;
security.LocalClientSettings.DetectReplays = true;
security.LocalClientSettings.ReplayCacheSize = 900000;
security.LocalClientSettings.MaxClockSkew = new TimeSpan(0, 5, 0);
security.LocalClientSettings.MaxCookieCachingTime = new TimeSpan(23, 0, 0, 0);
security.LocalClientSettings.ReplayWindow = new TimeSpan(0, 5, 0);
security.LocalClientSettings.SessionKeyRenewalInterval = new TimeSpan(15, 0, 0);
security.LocalClientSettings.SessionKeyRolloverInterval = new TimeSpan(0, 5, 0);
security.LocalClientSettings.ReconnectTransportOnFailure = true;
security.LocalClientSettings.TimestampValidityDuration = new TimeSpan(0, 5, 0);
security.LocalClientSettings.CookieRenewalThresholdPercentage = 60;
security.LocalServiceSettings.DetectReplays = true;
security.LocalServiceSettings.IssuedCookieLifetime = new TimeSpan(10, 0, 0);
security.LocalServiceSettings.MaxStatefulNegotiations = 128;
security.LocalServiceSettings.ReplayCacheSize = 900000;
security.LocalServiceSettings.MaxClockSkew = new TimeSpan(0, 5, 0);
security.LocalServiceSettings.NegotiationTimeout = new TimeSpan(0, 1, 0);
security.LocalServiceSettings.ReplayWindow = new TimeSpan(0, 5, 0);
security.LocalServiceSettings.InactivityTimeout = new TimeSpan(0, 2, 0);
security.LocalServiceSettings.SessionKeyRenewalInterval = new TimeSpan(15, 0, 0);
security.LocalServiceSettings.SessionKeyRolloverInterval = new TimeSpan(0, 5, 0);
security.LocalServiceSettings.ReconnectTransportOnFailure = true;
security.LocalServiceSettings.MaxPendingSessions = 128;
security.LocalServiceSettings.MaxCachedCookies = 1000;
security.LocalServiceSettings.TimestampValidityDuration = new TimeSpan(0, 5, 0);
var textEncoding = new TextMessageEncodingBindingElement
{
MaxReadPoolSize = 64,
MaxWritePoolSize = 16,
MessageVersion = MessageVersion.Default,
WriteEncoding = System.Text.Encoding.UTF8,
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxDepth = 32,
MaxArrayLength = 16384,
MaxBytesPerRead = 4096,
MaxNameTableCharCount = 16384,
MaxStringContentLength = 8192
}
};
var httpTransport = new HttpTransportBindingElement
{
ManualAddressing = false,
MaxBufferSize = 65536,
MaxReceivedMessageSize = 65536,
AllowCookies = false,
AuthenticationScheme = AuthenticationSchemes.Anonymous,
BypassProxyOnLocal = false,
DecompressionEnabled = true,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
KeepAliveEnabled = true,
MaxBufferPoolSize = 524288,
ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous,
TransferMode = TransferMode.Buffered,
UnsafeConnectionNtlmAuthentication = false,
UseDefaultWebProxy = true,
};
var binding = new CustomBinding(new List<BindingElement> { security, textEncoding, httpTransport });
var endpoint = new EndpointAddress(_serviceUri);
var service = new OrganizationServiceClient(binding, endpoint);