WCF 4 REST Max收到邮件大小

时间:2011-04-27 12:12:42

标签: wcf rest

我正在测试WCF 4 Rest界面。

当尝试使用小提琴手时,我会收到: “已超出传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。”

我试图在我的web.config文件中增加它,但它没有通过:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
  <webHttpEndpoint>
    <!-- 
        Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
        via the attributes on the <standardEndpoint> element below
    -->
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="327680" />
  </webHttpEndpoint>
</standardEndpoints>

谢谢, 的Mikkel

4 个答案:

答案 0 :(得分:1)

我今天刚遇到这个问题,弄清楚这有点痛苦。以下配置(根据this question的答案改编)应该有效:

<system.web>
  <!-- maxRequestLength is in KB -->
  <httpRuntime maxRequestLength="320" />
</system.web>

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
  <bindings>
    <webHttpBinding>
      <binding maxReceivedMessageSize="327680" />
    </webHttpBinding>
  </bindings>
  <standardEndpoints>
    <webHttpEndpoint>
      <standardEndpoint name=""
                        helpEnabled="true"
                        automaticFormatSelectionEnabled="true" />
    </webHttpEndpoint>
  </standardEndpoints>
</system.serviceModel>

我很确定你需要httpRuntime位,因为你在aspNetCompatibilityEnabled设置为true的情况下运行。

答案 1 :(得分:1)

按照web-config(在服务中)设置尝试:

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <standardEndpoints>

            <webHttpEndpoint>
                <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"                                        
                                  crossDomainScriptAccessEnabled="true" 
                                  maxReceivedMessageSize="2147483647" 
                                  maxBufferSize="2147483647" 
                                  maxBufferPoolSize="4194304" />
            </webHttpEndpoint>

    </standardEndpoints>

    <bindings>
        <webHttpBinding>
            <binding>
                <readerQuotas maxStringContentLength="2147483647"/>
            </binding>
        </webHttpBinding>
    </bindings>

</system.serviceModel>

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

答案 2 :(得分:0)

使用ActivityTracing以详细级别捕获WCF跟踪,并检查在Construct ServiceHost和Open ServiceHost活动下对您的服务应用的连接点。这将使您了解上述配置是否应用于服务。

HTH, 阿米特

答案 3 :(得分:0)

您是否在web.config(服务端)和客户端配置(文件)中增加了 MaxReceivedMessageSize 值?

如果是这样,您是否也可以尝试将 MaxBufferSize 增加到与 MaxReceivedMessageSize 相同的值?