2012-10-18 2 views
3

현재 Wcf 응용 프로그램을 사용 중이며 추적 로그에 흉내를 내고 있습니다.최대 요청 길이가 WCF를 초과했습니다.

다음은 Wcf 서비스 용 Web.Config입니다. 다음은

<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> 
는 클라이언트 측 구성이다.

 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); 

답변

3

당신은 바인딩의 readerQuotas을 설정해야 할 수도 있습니다 :

  WSHttpBinding binding1 = new WSHttpBinding(); 
      binding1.MaxBufferPoolSize = 2147483647; 
      binding1.MaxReceivedMessageSize = 2147483647;    

      var myReaderQuotas1 = new XmlDictionaryReaderQuotas(); 
      myReaderQuotas1.MaxStringContentLength = 2147483647; 
      myReaderQuotas1.MaxDepth = 2147483647; 
      myReaderQuotas1.MaxArrayLength = 2147483647; 
      myReaderQuotas1.MaxBytesPerRead = 2147483647; 
      myReaderQuotas1.MaxNameTableCharCount = 2147483647; 
      binding1.GetType().GetProperty("ReaderQuotas").SetValue(binding1, myReaderQuotas1, null); 

이유는 이미 생성 된 그 바인딩에 할당량을 설정하는 것은 아무 효과가 없다는 것입니다.

또한 클라이언트와 서버 모두에서 DataContractSerializer의 "MaxItemsInObjectGraph"값을 큰 값으로 늘려야합니다.

6

변경 Web.config의

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

XXXX에서 다음과 같은 설정은 그것에을 설정할 KB의 값입니다. 아래 그림과 같이

+3

주의 - 파일 크기를 제한 할 수있는 장소는 두 곳입니다. 위에서 언급 한 IIS와 WCF (끝점 구성, 다중 값) – Mario

관련 문제