我的WCF服务被公开以接收XML文件作为请求的一部分(使用SOAP UI进行测试(。在为服务端点启用基于证书的身份验证后,IIS引发HTTP/1.1 413 Request Entity Too Large
错误。若要解决此问题,请在IIS配置中将uploadReadAheadSize
的值更新为"20000000"。配置更改后,该服务能够成功处理该请求,当时从客户端收到的文件大小约为10MB。但后来,观察到了同样的问题,发现请求现在有大小从15MB到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_DataMyTestProjectXsdexchange-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>
此问题的实际原因是请求大小。有些请求的大小超过了30MB,导致了此错误。为了解决此问题,将IIS的maxAllowedContentLength
(system.webServer/security/requestFiltering(更新为50MB,默认情况下为30000000(30MB(