【问题标题】:Receiving Request Entity Too Large Error Even after updating the UploadReadAheadSize即使在更新 UploadReadAheadSize 之后,接收请求实体也出现太大错误
【发布时间】:2021-09-19 21:20:48
【问题描述】:

我的 WCF 服务公开接收 XML 文件作为请求的一部分(使用 SOAP UI 进行测试)。为服务端点启用基于证书的身份验证后,IIS 抛出 HTTP/1.1 413 Request Entity Too Large 错误。为解决此问题,在 IIS 配置中将 uploadReadAheadSize 的值更新为“20000000”。配置更改后服务能够成功处理请求,当时从客户端接收到的文件大小约为 10MB。但后来,观察到同样的问题,发现请求现在具有大小从 15 MB 到 30MB 不等的 XML 文件。 要解决此问题,请将 uploadReadAheadSize 增加到“90000000”(尝试使用更高的值)。但这个问题一直存在。 有解决此问题的建议吗?

当前服务配置:

<bindings>
    <basicHttpsBinding>
        <binding name="BasicHttpBinding.MyService" transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" receiveTimeout="00:30:00">
            <readerQuotas maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxArrayLength="2147483647" />
            <security mode="Transport">
                <transport clientCredentialType="Certificate" />
            </security>
        </binding>
    </basicHttpsBinding>
</bindings>
<behaviors>
    <serviceBehaviors>
        <behavior name="MyTestProjectIntegrationServiceBehavior">
            <serviceCredentials>
                <serviceCertificate findValue="****************************" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
            </serviceCredentials>
            <serviceMetadata httpsGetEnabled="true" />
            <CustomBehaviorExtensionElement />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
        <behavior name="MyServiceEndpointBehavior">
            <MyServiceSchemaValidator validateRequest="True" validateReply="False">
                <schemas>
                    <add location="App_Data\MyTestProjectXsd\exchange-model-service.xsd" />
                </schemas>
            </MyServiceSchemaValidator>
        </behavior>
    </endpointBehaviors>
</behaviors>
<system.serviceModel>
    <services>
        <service name="Test.Project.ServiceImplementation.MyService" behaviorConfiguration="MyTestProjectIntegrationServiceBehavior">
            <endpoint binding="basicHttpsBinding" bindingConfiguration="BasicHttpBinding.MyService" contract="ExchangeMyProjectService" behaviorConfiguration="MyServiceEndpointBehavior" bindingNamespace="http://www.test.com/api/end/service" />
        </service>
    </services>
</system.serviceModel>

【问题讨论】:

  • 您可以尝试:首先在站点的根web.config中设置请求限制(默认为30 MB)。这也可以在 Internet Information Services Manager Program 中设置(MACHINE->Site->IIS->Request Filtering->Edit Feature Settings)。其次,您可以尝试 httpRuntime maxRequestLength="4194304" 。如果它不起作用,请尝试 maxAllowedContentLength="2147483648" 接下来。如果它不起作用,请尝试 maxReceivedMessageSize="10485760" 接下来。最后尝试 maxRequestLength="4194301" 如果它不起作用,请稍等。

标签: web-services wcf iis wcf-binding


【解决方案1】:

此问题的实际原因是请求大小。一些请求超过 30MB 并导致此错误。为了解决这个问题,将IIS的maxAllowedContentLength(system.webServer/security/requestFiltering)更新为50MB,默认为30000000(30MB)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 2018-07-07
    • 2016-08-05
    • 2016-02-10
    • 2016-02-01
    • 2018-12-14
    • 1970-01-01
    相关资源
    最近更新 更多