且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Wcf-传入消息的最大消息大小配额 (65536) 已超出?

更新时间:2021-08-14 23:16:24

您应该设置 maxReceivedMessageSize="2147483647" 以增加消息大小.尝试将配置更改为:

You should set maxReceivedMessageSize="2147483647" to increase message size. Try to change config to this:

<binding maxBufferSize="2147483647" 
         maxBufferPoolSize="2147483647" 
         maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" 
                  maxStringContentLength="2147483647" 
                  maxArrayLength="2147483647" 
                  maxBytesPerRead="2147483647"
                  maxNameTableCharCount="2147483647" />
</binding>

但是将消息值增加到最大值是一种不好的做法.这可能会导致您遇到 DOS 泄漏的严重问题.

But it is a bad practice to increase you message values to max value. This can lead you to serious troubles with DOS leaks.

更新:

<system.serviceModel>
  <bindings>
   <wsHttpBinding>
    <binding name="wsBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"  >
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
    </binding>
   </wsHttpBinding> 
  </bindings>
  <services>
  <service name="FileService.Service1" behaviorConfiguration="FileService.Service1Behavior">
  <host>
    <baseAddresses>
      <add baseAddress = "http://localhost:8732/Design_Time_Addresses/FileService/Service1/" />
    </baseAddresses>
  </host>
   <endpoint address ="" binding="wsHttpBinding" bindingConfiguration="wsBinding" contract="FileService.IService1">   
   <identity>
    <dns value="localhost"/>
   </identity>
 </endpoint>

 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
 </service>
 </services>
 <behaviors>
   <serviceBehaviors>
     <behavior name="FileService.Service1Behavior">    
       <serviceMetadata httpGetEnabled="True"/>    
       <serviceDebug includeExceptionDetailInFaults="False" />
     </behavior>
   </serviceBehaviors>
 </behaviors>
</system.serviceModel>