【问题标题】:How to send large Messages to the WCF Services?如何向 WCF 服务发送大消息?
【发布时间】:2011-09-13 13:25:32
【问题描述】:

我在 WCF 服务中有一个 DataContract。它有一个数组,我在客户端代码中设置该数组。如果我将数组设置为超过 1000,000,它会抛出一个错误,说 BadRequest。 System.ServiceModel.ProtocolException : 远程服务器返回了意外响应 (400) 错误请求。

如何克服这个问题?我想向服务发送更多数据。

【问题讨论】:

    标签: message-passing wcf


    【解决方案1】:

    您可以尝试增加允许的消息大小。您需要同时设置服务和客户端端点以使用绑定配置。

        <bindings>
            <netTcpBinding>
                <binding name="TcpBindingConfiguration" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                </binding>
            </netTcpBinding>
        </bindings>
    

    如果您尝试发送的数据无法满足上述配置所允许的消息大小,您将需要寻找发送更少数据或在多个请求中发送的方法。

    相关信息可以看this question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多