【问题标题】:WCF exception - "Service not found" when retrieving large collectionWCF 异常 - 检索大型集合时“找不到服务”
【发布时间】:2012-01-13 12:43:33
【问题描述】:

我的 WCF 服务被 Silverlight 应用程序用于检索数据。我没问题,

    [OperationContract]
MyCollectionClass GetList(int sessID, string name);

  [CollectionDataContract]
public class MyCollectionClass : List<MyClass>{ }

  [DataContract]
public class MyClass {

  [DataMember]
  public string Prop1 { get; set; }

  [DataMember]
  public string Prop2 { get; set; }

}

但是.. 当 MyCollectionClass 的“记录”少于 3000 条时,它会起作用。当记录数较多时,WCF 服务似乎可以工作,但在 Silverlight 应用程序的已完成事件上发生异常:“未找到服务”。
我发现这可能与服务配置有关,我已经尝试使用两者:

maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"

关于 WCF 和客户端配置。还添加了:

readerQuotas: 
  maxArrayLength="2000000" 
  maxStringContentLength="2000000"/>

(也更改了找到的值)但似乎不起作用。 我认为问题在于消息超出了每个“消息”的最大字节数,但我不明白为什么数据没有跨越不同的消息。
任何提示表示赞赏。

乔治

【问题讨论】:

    标签: wcf silverlight web-services


    【解决方案1】:

    我有同样的问题,在我的情况下只是序列化一个字符串并且没有问题,但是在你的情况下你正在序列化一大堆对象,这是一个默认限制,我记得我看过一篇关于那个的帖子(只是配置中的一个设置 --> maxItemsInObjectGraph)来增加序列化对象的数量,

    链接

    http://silverlight.net/forums/t/17674.aspx http://forums.asp.net/t/1330713.aspx

    设置:

    HTH 布劳略

    【讨论】:

    • 成功的部分是: 我只管理了前2个。现在它可以工作了:D。谢谢
    【解决方案2】:

    尝试在服务器端启用 wcf 服务日志记录。这可能会有所帮助:http://msdn.microsoft.com/en-us/library/ms730064.aspx

    【讨论】:

      【解决方案3】:

      我在 InitializeComponent 之后使用这两个语句:

      binding.MaxReceivedMessageSize = 5000000 binding.MaxBufferSize = 5000000

      您可以将数字更改为您想要的,但我必须这样做才能在 Silverlgiht 客户端上接收大量数据。我的绑定对象定义为:

      私有绑定作为新的 BasicHttpBinding

      这是在 vb.net 中。加入这些物品后,效果就像一个魅力。

      【讨论】:

        【解决方案4】:
        【解决方案5】:

        我使用silverlight 4和vs 2010,我也遇到了同样的问题,我解决了修改web.config文件的问题。

        我原来的 web.config 文件有:

        <system.serviceModel>
           <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        </system.serviceModel>
        

        我改变了它:

          <system.serviceModel>
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
            <behaviors> 
                 <serviceBehaviors> 
                     <behavior> 
                         <serviceMetadata httpGetEnabled="true"/> 
                         <serviceDebug includeExceptionDetailInFaults="true"/> 
                         <dataContractSerializer maxItemsInObjectGraph="2147483647"/>  <!--this very is important: it is the size of the buffer-->
                     </behavior> 
                 </serviceBehaviors> 
             </behaviors>
          </system.serviceModel>
        

        【讨论】:

          【解决方案6】:

          我可以建议您减少要返回的记录数吗?不是作为解决方法,而是作为可用性建议。我无法想象任何用户都可以处理 3000 多条记录。如果您要从数据集中聚合值而不是在服务器端聚合它们,它将大大提高您的应用程序的性能......我在我的应用程序中遇到过几次这种情况,而且几乎总是比更改设计更好选项...

          【讨论】:

          • 很遗憾,当时没有这种选择。
          猜你喜欢
          • 2012-05-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2010-12-11
          • 2011-09-12
          • 1970-01-01
          • 2019-04-13
          相关资源
          最近更新 更多