Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
946 views
in Technique[技术] by (71.8m points)

wcf binding - Maximum request length exceeded in WCF

I am currently using Wcf application and getting above mentiooned error in Trace Log.

Below is the Web.Config for Wcf Service.

<bindings>
          <wsHttpBinding>
              <binding name="NewBinding0" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                  <reliableSession enabled="true" />
                  <security mode="None">
                      <transport clientCredentialType="None" />
                      <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
                  </security>
              </binding>
          </wsHttpBinding>
      </bindings>       

<diagnostics wmiProviderEnabled="true">
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
  <service behaviorConfiguration="DBSyncWcfService.Service1Behavior" name="DBSyncWcfService.DBSyncService">
    <endpoint binding="wsHttpBinding" bindingConfiguration="NewBinding0" name="ABC" contract="DBSyncWcfService.IDBSyncContract" address="http://192.168.5.170:9999/" />
    <host>
      <baseAddresses>

Below is the Client side Configuration.

        WSHttpBinding binding = new WSHttpBinding();
        //binding.ReaderQuotas.MaxArrayLength = 10485760;

        //binding.MaxReceivedMessageSize = 10485760;
        binding.Security.Mode = SecurityMode.None;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
        binding.Security.Message.EstablishSecurityContext = false;
        //binding.Security.Message.NegotiateServiceCredential = true;
        binding.ReliableSession.Enabled = true;
        binding.ReaderQuotas.MaxArrayLength = 2147483647;
        binding.ReaderQuotas.MaxDepth = 2147483647;
        binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
        binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
        //binding.MaxReceivedMessageSize = 20000000;2147483647
        binding.MaxReceivedMessageSize = 2147483647;
        //binding.MaxReceivedMessageSize = Int32.MaxValue;
        binding.ReaderQuotas.MaxStringContentLength = 2147483647; 

        //binding.MaxBufferPoolSize = 20000000;
        binding.MaxBufferPoolSize = 2147483647;

        //binding.MaxBufferPoolSize = Int32.MaxValue;
        binding.ReaderQuotas.MaxArrayLength = 2147483647;
        binding.ReaderQuotas.MaxDepth = 2147483647;
        binding.SendTimeout = TimeSpan.FromMinutes(50);
        binding.CloseTimeout = TimeSpan.FromMinutes(50);
        binding.OpenTimeout = TimeSpan.FromMinutes(50);
        binding.ReceiveTimeout = TimeSpan.FromMinutes(50);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Change the following setting in web.config

 <configuration> 
    <system.web> 
        <httpRuntime maxRequestLength="xxxx" /> 
    </system.web> 
</configuration> 

xxxx is the value in KB you want to set it to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...