maxReceivedMessageSize WCF

时间:2014-12-03 18:16:04

标签: c# wcf maxreceivedmessagesize

我使用WCF服务,但我遇到了问题

  

传入邮件的最大邮件大小限额(65536)   超标。要增加配额,请使用MaxReceivedMessageSize   适当的绑定元素上的属性。

我修改了MaxReceivedMessageSize,但没有结果(我在互联网上阅读了很多文章,但任何人都无法帮助)

谁知道这个?

Service.config:

<system.serviceModel>       
   <bindings>           
      <wsHttpBinding>
         <binding name="BindingWithMaxSizeIncreased" 
                  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                          maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
                          maxNameTableCharCount="2147483647" />
         </binding>             
      </wsHttpBinding>      
   </bindings>      
   <services>           
      <service name="FootballLife.MyService" behaviorConfiguration="metadataBehavior">
         <endpoint 
             address="" 
             binding="wsHttpBinding" bindingConfiguration="BindingWithMaxSizeIncreased" 
             contract="FootballLife.IMyService">
            <identity>
               <dns value="localhost"/>
            </identity>
         </endpoint>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>        
   </services>      
   <behaviors>          
      <serviceBehaviors>
         <behavior name="metadataBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
         </behavior>            
      </serviceBehaviors>       
   </behaviors>         
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
                              multipleSiteBindingsEnabled="true" />   
</system.serviceModel>

Client.config

<system.serviceModel>
   <bindings>
      <wsHttpBinding>
          <binding name="BindingWithMaxSizeIncreased"
                   maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                            maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
                            maxNameTableCharCount="2147483647" />
          </binding>
      </wsHttpBinding>
   </bindings>
   <client>
      <endpoint 
          address="http://localhost:90/MyService.svc" 
          binding="wsHttpBinding" 
          contract="IMyService">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
   </client>
</system.serviceModel>

1 个答案:

答案 0 :(得分:1)

您需要在客户端配置中为端点提供自定义bindingConfiguration:

<endpoint address="http://localhost:90/MyService.svc" 
    binding="wsHttpBinding" 
    contract="IMyService"
    bindingConfiguration="BindingWithMaxSizeIncreased">
    <identity>
        <dns value="localhost" />
    </identity>
</endpoint>