2011-04-09 75 views
6

我有一个应用程序使用WCF和netTcpBinding上传大文件。对于特定文件,我收到错误消息:传入消息的最大消息大小配额已被超出(明显的修复不起作用)

传入消息(65536)的最大消息大小配额已超出。要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

这是我在客户web.config文件绑定(客户端是一个ASP.NET网站):

<binding name="DataImportEndpoint" closeTimeout="00:20:00" openTimeout="00:01:00" 
     receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="Buffered" 
     hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
     maxBufferSize="5242880" maxReceivedMessageSize="5242880"> 
     <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="Transport"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     </security> 
    </binding> 

我意识到我还需要更改服务配置的maxReceivedMessageSize财产。所以我加了这个结合:

<bindings> 
    <netTcpBinding> 
    <binding name="NetTcpLarge" 
      maxReceivedMessageSize="5242880" maxBufferSize="5242880"> 
     <readerQuotas maxStringContentLength="524288"/> 
    </binding> 
    </netTcpBinding> 
</bindings> 

和修改我的终点:

<endpoint address="DataImportService" binding="netTcpBinding" 
     name="DataImportEndpoint" bindingConfiguration="NetTcpLarge" 
     contract="IDataImportService" /> 

这个固定的问题,当我运行的自我在Visual Studio主办。但是,在IIS 7上运行的实例中,我是仍然获得与65536已超出相同的错误。我在这里错过了什么吗?我甚至已将此添加在IIS 7例如我的服务配置,但无济于事:

<system.webServer> 
    <security> 
     <requestFiltering> 
      <requestLimits maxAllowedContentLength="5242880" /> 
     </requestFiltering> 
    </security> 
</system.webServer> 

回答

6

如果异常仍是相同的IIS,它无关<requestLimits>,除了清楚地表明,maxReceivedMessageSize超过。我将捕获详细级别的WCF跟踪并检查在端点上应用了哪些绑定配置。

我建议你重新检查客户端和服务配置,如果仍然没有线索,请在详细级别捕获服务和客户端的跟踪。

+2

确实,绑定配置没有被应用。 web.config中的服务名称与.svc文件(其中一个具有完整的名称空间)中的服务名称不匹配,因此正在应用默认端点!感谢您的建议 – pjacko 2011-04-18 14:53:57

0

听起来像你可能会超过IIS的“maxRequestLength”缓冲区大小。默认的大小是......你猜,65536.尝试添加以下行到你的web.config文件:

<system.web> 
    <compilation debug="true"/> 
    <httpRuntime maxRequestLength="5242880"/> 
</system.web> 
+3

默认大小为4096 KB(4 MB)。 http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx – StarCub 2011-11-27 22:20:07

相关问题