【问题标题】:WCF: 413 Request Entity Too LargeWCF:413 请求实体太大
【发布时间】:2016-06-17 08:46:26
【问题描述】:

我已经阅读了很多关于它的帖子,但我不知道我的 web.config 会发生什么。

这是 de web.config 代码:

  <system.serviceModel>
<client>
  <endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0"
    contract="Service.IService" />
</client>
<bindings>
  <basicHttpBinding>
    <binding name="NewBinding0" closeTimeout="00:05:00" openTimeout="00:05:00"
      sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
      maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="NewBinding1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
      maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

很抱歉,我不熟悉 web.conf 文件。我读过我必须设置 maxReceivedMessageSize,但我已经完成了,我收到了同样的错误。

我正在使用 Microsoft 服务配置编辑器编辑文件。 我尝试过使用 basicHttpBinding 和不使用 webHttpBinding,但不起作用。

每次调用 WCF 时,都会收到相同的错误。

在 SOAPUI 中尝试,当消息大小小于 65537 时,它可以工作。当消息大小超过 65536 时,它不起作用。

提前谢谢。

卡尔斯

【问题讨论】:

标签: wcf iis web-config


【解决方案1】:

这是app.config的工作代码-

<bindings>
    <webHttpBinding>
        <binding name="myBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed" >
            <readerQuotas maxDepth="64" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
        </binding>
    </webHttpBinding>
</bindings>
<services>
    <service behaviorConfiguration="ForecastREST_API.RESTServiceImplBehavior" name="ForecastREST_API.RestServiceImpl">
        <endpoint address="http://localhost:59624/RestServiceImpl.svc" binding="webHttpBinding" contract="ForecastREST_API.IRestServiceImpl" behaviorConfiguration="Web" bindingConfiguration="myBinding">
            </identity>
        </endpoint>
        <endpoint address="mex" binding="webHttpBinding" contract="IMetadataExchange"/>
    </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="Web">
            <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            <webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
            <dispatcherSynchronization asynchronousSendEnabled="true" />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="ForecastREST_API.RESTServiceImplBehavior">
            <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
    </serviceBehaviors>
</behaviors>

【讨论】:

    【解决方案2】:

    maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" 和 bindingConfiguration="myBinding" 仅在服务端点部分很重要,并且在我的项目中也需要 bindingName。

    【讨论】:

      猜你喜欢
      • 2016-09-08
      • 2020-02-05
      • 2011-02-22
      • 1970-01-01
      • 2016-11-14
      • 2014-12-30
      • 2014-12-23
      • 1970-01-01
      相关资源
      最近更新 更多