【问题标题】:WCF Service msg Size ErrorWCF 服务消息大小错误
【发布时间】:2014-03-27 05:43:11
【问题描述】:

我有两个独立的模块(基于 Web 的 GUI 和基于 WCF 的服务器),我正在使用 WCF 服务引用来访问从我的 GUI 到服务器的一些方法。当 GUI 向服务器请求数据并将大量数据发送到 GUI 时,会出现此问题;抛出最大消息大小错误异常! 我在 Web.config 文件的适当部分标记中增加了消息大小,它暂时起作用,但是当数据(在我的情况下总是增长)达到最大允许大小时,错误再次发生!我知道瓶颈在 GUI 一侧! 我该如何解决这个问题,有没有办法让 GUI 服务引用来处理不断增长的数据? 这是我的 GUI web.config 文件:

<pre>
</system.webServer>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IServerHelper" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="16777216" maxBufferPoolSize="524288" maxReceivedMessageSize="16777216" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" >
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://172.16.16.7:123456/ServerServices" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServerHelper" contract="ServiceReference1.IServerHelper" name="BasicHttpBinding_IServerHelper"/>
    </client>
</system.serviceModel>
</pre>

谢谢你帮助我...

【问题讨论】:

    标签: wcf web service reference


    【解决方案1】:

    您最多可以将这些值设置为int.MaxValue。如果这对于您的返回消息仍然不够,您应该尝试拆分您的消息。毕竟,那将是 2GB 的消息。也许 SOAP 并不是运输这种野兽的最佳方式。

    【讨论】:

    • 如何拆分我的消息?你建议什么替代方案? (提供代码示例很棒!)
    • @user2240957 这在很大程度上取决于您的用例。特别是考虑到通过 SOAP 发送 2GB 并不是一个好的开始方式。如果您需要获取 2GB 数据,请考虑一种更适合该任务的方法。您的客户端是否有 6GB RAM?因为如果您在 GUI 中执行 MVVM 并从您的服务中获得 2GB,这就是您所需要的。
    • 你说得对!我应该使用更合适的解决方案
    • 但是在当前场景下是否可以最大化 GUI 上的接收数据容器大小? web.config 中有一些我不知道它们的好处的参数(比如 maxArrayLength ...)
    • @user2240957 您可以将它们全部设置为int.MaxValue 或者在数字上相等,但是您有实际问题吗?如果您有错误消息,请发布。
    猜你喜欢
    • 2015-04-02
    • 2017-05-05
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    • 2012-01-26
    • 2013-08-28
    • 2010-09-27
    • 1970-01-01
    相关资源
    最近更新 更多