【问题标题】:Entity too large Error实体太大错误
【发布时间】:2014-05-23 05:00:51
【问题描述】:

我的服务有点问题。它不支持大量数据,我必须为它发送一个用base64编码的图像。 服务配置是这样的:

[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "create", BodyStyle = WebMessageBodyStyle.Bare)]
WSResult<WebService.Model.Order> create(WSOrderCreateParams paramsData);

而 web.config 有这样的配置:

<system.web>
    <compilation targetFramework="4.5" debug="true" />
    <httpRuntime targetFramework="4.5" maxRequestLength="1000000000"/>
<system.web>
...
<service.serviceModel>
...
  <webHttpBinding>
    <binding name="WebHttpEndpointBinding"
      maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </webHttpBinding>
...
</service.serviceModel>
...
<services>
  <service name="WebService.ws.Order">
    <endpoint address="" behaviorConfiguration="Web" binding="webHttpBinding" contract="WebService.ws.IOrder"/>
  </service>
</services>

谁能帮帮我?

【问题讨论】:

  • 您是否尝试过将文件分成多个块,然后让网络服务将它们重新组合在一起?
  • 在您的&lt;service&gt; 上,尝试添加bindingConfiguration="WebHttpEndpointBinding"
  • @javisrk,我该怎么做?
  • @kei,试过了,没用
  • stackoverflow.com/questions/7853467/… 有一个使用 HTML5 文件 API 上传块的示例 - 服务器示例是 PHP,但客户端示例是标准 javascript。

标签: c# wcf


【解决方案1】:

我已经通过网络配置解决了。这就是 Web.config 现在的样子:

<system.web>
  <compilation targetFramework="4.5" debug="true" />
  <httpRuntime targetFramework="4.5" maxRequestLength="1000000000"/>
<system.web>
    ...
<service.serviceModel>
  ...
  <webHttpBinding>
    <binding name="WebHttpEndpointBinding"
      maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </webHttpBinding>
  ...
</service.serviceModel>
    ...
<services>
  <service name="WebService.ws.Order">
    <endpoint address="" bindingConfiguration="WebHttpEndpointBinding" behaviorConfiguration="Web" binding="webHttpBinding" contract="WebService.ws.IOrder"/>
  </service>
</services>
...
<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
  </security>
  <serverRuntime uploadReadAheadSize="2147483647" />
</system.webServer>

我已经在服务中添加了 bindingConfiguration,就像@kei 说的那样,并且

<serverRuntime uploadReadAheadSize="2147483647" /> 

在 system.webServer。 IIS 的默认池不允许您使用 uploadReadAheadSize,因此您必须继续:IIS 管理器 > 配置编辑器 > 部分:system.webServer/serverRuntime > 解锁部分。这样做,它应该工作:)

【讨论】:

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