【问题标题】:Large WCF result sending in to Silverlight app大型 WCF 结果发送到 Silverlight 应用程序
【发布时间】:2014-01-16 22:40:31
【问题描述】:

我目前有一个 Silverlight 应用程序调用 WCF 服务,该服务返回大约 7000 个对象。我们可以让它返回大约 6500 个对象,但返回整个集合失败。如果我们从 DTO 中删除一个属性,但重新添加它会导致失败,它也允许我们。

我们的客户端配置如下:

    <basicHttpBinding>
        <binding name="EchoWCFBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"></binding>
    </basicHttpBinding>

我们的服务器配置如下:

  <basicHttpBinding>
    <binding name="simpleHttp" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm"/>
      </security>
    </binding>
  </basicHttpBinding>

我们使用 ChannelFactory 连接到服务,如果我们增加客户端上的 maxReceivedMessageSize,它会在构造时抛出异常,说它必须是一个 int。

【问题讨论】:

  • WCF 服务设置很糟糕,我因类似的错误损失了好几天。如果您没有获得完整的异常信息(即您收到可怕的“NotFound”错误),您应该启用日志记录,然后您将获得更多信息。有关获取更多信息的答案,请参阅 SO 文章 [stackoverflow.com/questions/2316201/…。这个博客:[softarchitect.wordpress.com/2010/06/30/… 也有关于日志记录的有用信息,我用来查看我的异常内部。

标签: c# wcf silverlight


【解决方案1】:

试试这个,

 <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>        
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
   <bindings>
      <basicHttpBinding>
        <binding name="" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" >
          <readerQuotas maxArrayLength="2147483647"
   maxBytesPerRead="2147483647"
   maxDepth="2147483647"
   maxNameTableCharCount="2147483647"
   maxStringContentLength="2147483647"  />
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
    </bindings>

【讨论】:

    【解决方案2】:

    我用代码解决了这个问题,实际上提供了更好的用户体验。我将列表拆分为可管理的块,并通过单独的客户端请求通过网络发送它们。有了这个,我能够提供一个进度条。

    【讨论】:

      猜你喜欢
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 2010-11-02
      • 2014-10-28
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      相关资源
      最近更新 更多