我使用 WSFederationHttpBinding 的性能很差 - iis 每秒只处理 250 个请求。
捆绑:
public class CustomFactoryActive : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
ServiceHost host = new ServiceHost(serviceType, baseAddresses);
CommonConf.ConfigureServiceHost(host);
string issuerAddress = ConfigManager.ActiveSTS;
string issuerMexAddress = issuerAddress + "/mex";
WSFederationHttpBinding wsFedBinding = new WSFederationHttpBinding();
wsFedBinding.Security.Mode = WSFederationHttpSecurityMode.Message;
wsFedBinding.ReliableSession.Enabled = false;
wsFedBinding.MaxReceivedMessageSize = wsFedBinding.MaxBufferPoolSize = Constants.MaxFileSize;
XmlDictionaryReaderQuotas quotas = wsFedBinding.ReaderQuotas;
quotas.MaxArrayLength = quotas.MaxBytesPerRead = quotas.MaxStringContentLength =
quotas.MaxNameTableCharCount = quotas.MaxDepth = (int)Constants.MaxFileSize;
var messageSecurity = wsFedBinding.Security.Message;
messageSecurity.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
messageSecurity.IssuedKeyType = SecurityKeyType.SymmetricKey;
messageSecurity.EstablishSecurityContext = false;
messageSecurity.NegotiateServiceCredential = false;
messageSecurity.IssuerAddress = new EndpointAddress(new Uri(issuerAddress));
messageSecurity.IssuerMetadataAddress = new EndpointAddress(new Uri(issuerMexAddress));
WS2007HttpBinding ws2007HttpBinding = new WS2007HttpBinding(SecurityMode.TransportWithMessageCredential);
var wsHttpSecurity = ws2007HttpBinding.Security;
wsHttpSecurity.Message.ClientCredentialType = MessageCredentialType.UserName;//авторизация по логину и паролю
wsHttpSecurity.Message.NegotiateServiceCredential = true;
wsHttpSecurity.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
messageSecurity.IssuerBinding = ws2007HttpBinding;
ContractDescription contractDescription = ContractDescription.GetContract(typeof(ISignService));
EndpointAddress endpointAddress = new EndpointAddress(baseAddresses[0]);
ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, wsFedBinding, endpointAddress);
host.Description.Endpoints.Add(endpoint);
return host;
}
}
我的 wcf 测试方法什么都不做——它只返回 1 个字节。
但是当我在没有任何 WIF saml 令牌的情况下使用具有消息安全性的简单 WSHttpBinding 时,我得到了大约。每秒 4000 个请求
我不明白为什么