WCF为大请求返回404,maxReceivedMessageSize ="2147483647"

Dam*_*ski 3 wcf

我们对大型请求的WCF服务返回以下错误:

"System.ServiceModel.EndpointNotFoundException:http://xxx.svc上没有可以接受消息的端点.这通常是由不正确的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在). - > System.Net.WebException:远程服务器返回错误:(404)Not Found.

对于小请求,一切正常,我从WCF服务得到正确的响应,问题仅在于大量请求.

客户端上的设置如下:

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITestService" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" >
          <readerQuotas maxDepth="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
            maxNameTableCharCount="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:33333/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestService" name="BasicHttpBinding_ITestService" />
    </client>
  </system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

WCF服务的设置:

 <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
Run Code Online (Sandbox Code Playgroud)

可能是什么问题?

Dam*_*ski 13

在这种情况下,错误不是使用WCF而是使用IIS设置.消息对于IIS来说很大,我在服务器上的web.config中添加了" maxAllowedContentLength ".

<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2200000000"/>
      </requestFiltering>
    </security>
Run Code Online (Sandbox Code Playgroud)

错误消息具有误导性.