我之前在这里写过一个关于类似问题的问题,但是我已经对正确执行绑定和行为的正确方法进行了更多测试和研究,尽管我现在有了更好的理解,但我仍然遇到这个被清除的错误。我什至浏览了客户端并以编程方式创建了绑定,以便我可以确定它使用了正确的设置。
客户端程序:
public static UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient MakeClient(string endpointUri)
{
UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient client = null;
// replicate all the binding info from app.config
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "MaxSizeBasicBinding";
// The interval of time for a connection to open, before the transport raises an exception.
binding.OpenTimeout = TimeSpan.FromMinutes(1);
// The interval of time that a connection can remain active, during which no application
// messages are received, before it is dropped. This one is NOT important.
binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
// The interval of time for an operation to complete before the transport raises an exception.
// This one is important. The time here was increased so that a command to the Negotiator
// has more than the default of one minute before it times out. Given that the Negotiator
// tries 3 times on any database command, a total of 3 minutes, CBH changed this to 5 on 2/3/12.
binding.SendTimeout = TimeSpan.FromMinutes(5); // used to be 1
binding.CloseTimeout = TimeSpan.FromMinutes(1);
binding.AllowCookies = false;
binding.BypassProxyOnLocal = false;
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.MessageEncoding = WSMessageEncoding.Text;
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.TransferMode = TransferMode.Buffered;
binding.UseDefaultWebProxy = true;
//int maxMessageSize = 1024 * 1024; // reasonable size w/o allocating huge amt of memory
// That 1MB was not big enough, so increase it to half the limit, 1,073,741,824
int maxMessageSize = 1024 * 1024 * 1024;
binding.MaxBufferSize = maxMessageSize;
binding.MaxReceivedMessageSize = maxMessageSize;
binding.ReaderQuotas.MaxBytesPerRead = maxMessageSize;
binding.ReaderQuotas.MaxStringContentLength = maxMessageSize;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
try
{
System.Net.AuthenticationManager.CredentialPolicy = null;
EndpointAddress endpointAddress = new EndpointAddress(endpointUri);
client = new UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient(binding, endpointAddress);
//client.ClientCredentials.Windows.AllowedImpersonationLevel =
// System.Security.Principal.TokenImpersonationLevel.Impersonation;
}
catch (Exception ex)
{
throw ex;
}
return client;
}
服务端 (Web.config)
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Configuration" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicBindingMaxLength" maxBufferSize="1073741824"
maxReceivedMessageSize="1073741824">
<readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824"
maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824" />
<security mode="TransportCredentialOnly">
<!--<transport clientCredentialType="Windows" />-->
</security>
</binding>
</basicHttpBinding>
</bindings>
<service behaviorConfiguration="UserAnalyticsSvcBehaviors" name="CISE.ServiceEngine.MasterEngineProxy.Services.UserAnalyticsMasterService">
<endpoint address="" binding="basicHttpBinding" behaviorConfiguration="Behaviors.EndpointBehavior" bindingConfiguration="BasicBindingMaxLength"
contract="CISE.ServiceEngine.MasterEngineProxy.Interfaces.IUserAnalyticsMasterService">
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<behavior name="UserAnalyticsSvcBehaviors">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
如果有人可以在这里帮助我,我已经为此工作了好几天,似乎无法想出默认设置的位置