开发者

WCF 4 REST Max recevied message size

开发者 https://www.devze.com 2023-02-28 20:43 出处:网络
I am testing a WCF 4 Rest interface. When trying to do a ge开发者_JAVA技巧t using fiddler I receive this:

I am testing a WCF 4 Rest interface.

When trying to do a ge开发者_JAVA技巧t using fiddler I receive this: "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."

I have tried to increase it in my web.config file but it does not come through:

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

Thanks, Mikkel


I just ran into this today, and it was a bit of a pain to figure out. The following config (adapted from the answer to this question) should work:

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

I'm pretty sure you need the httpRuntime bit because you're running with aspNetCompatibilityEnabled set to true.


Try it by following web-config(in Service) settings :

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


Capture WCF traces at verbose level with ActivityTracing and check what enpoints are applied on your service under Construct ServiceHost and Open ServiceHost activity. That will give you idea whether above configuration is applied on service or not.

HTH, Amit


Have you increased the MaxReceivedMessageSize value in both the web.config (service-side) and in your client's configuration (file)?

If so, can you also try to increase MaxBufferSize to the same value as MaxReceivedMessageSize?

0

精彩评论

暂无评论...
验证码 换一张
取 消