【问题标题】:WCF Service "The remote server returned an error: (413) Request Entity Too Large."WCF 服务“远程服务器返回错误:(413) 请求实体太大。”
【发布时间】:2016-06-10 04:49:47
【问题描述】:

我正在开发一个使用 wsHTTPBinding 的 WCF 服务,当我在某个时刻使用我的客户端测试应用程序进行调用时,我收到错误远程服务器返回了意外响应:The remote server returned an error: (413) Request Entity Too Large.

我的 web.config 中服务的绑定配置如下:

        <wsHttpBinding>
            <binding name="secureHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" />
                </security>
            </binding>
        </wsHttpBinding>

以及服务端的端点:

        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureHttpBinding" contract="WS_UCC_XML.IWS_UCC_XML" />

以及客户端中的绑定配置:

        <wsHttpBinding>
            <binding name="wsHttpBinding_IWS_UCC_XML_SSL" maxBufferPoolSize="2147483647"
                maxReceivedMessageSize="2147483647"  receiveTimeout="01:00:00" sendTimeout="01:00:00">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" />
                </security>
            </binding>
        </wsHttpBinding>

【问题讨论】:

  • 1) 这可能是服务端的设置,而不是客户端的设置。 2)您的服务配置中是否定义了明确的端点?除非将其分配给端点,否则不会使用配置中的绑定定义。请发布您的服务配置的完整&lt;system.serviceModel&gt;部分。
  • 我在问题中添加了端点配置。
  • 尝试为 system.webServer->security->reqestFiltering 中 &lt;requestLimits&gt; 元素的 maxAllowedContentLength 属性设置上限。定义的绑定看起来是正确的。

标签: c# wcf


【解决方案1】:

将maxBufferSize="2147483647"参数添加到config中的客户端和服务器绑定标签中:

<binding name="secureHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">

也试试 MaxItemsInObjectGraph - 将以下内容添加到服务器和客户端的“system.serviceModel”部分:

<commonBehaviors>
  <endpointBehaviors>
    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
  </endpointBehaviors>
  <serviceBehaviors>
     <dataContractSerializer maxItemsInObjectGraph="2147483647" />
  </serviceBehaviors>
</commonBehaviors>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-08
    • 2014-07-23
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-18
    • 2021-02-22
    • 1970-01-01
    相关资源
    最近更新 更多