WCF:413请求实体太大

时间:2016-06-17 08:46:26

标签: wcf iis web-config

我已经阅读了很多关于它的帖子,但我不知道我的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 Service Configuration Editor编辑文件。 我尝试过使用basicHttpBinding而没有使用webHttpBinding,但是没有用。

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

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

提前做出来。

卡尔斯

2 个答案:

答案 0 :(得分:0)

以下是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>

答案 1 :(得分:0)

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