调用WCF时报错:服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。

来源:互联网 发布:mac下面工具栏不见了 编辑:程序博客网 时间:2024/06/05 23:06

报错:服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。


可能原因:

1、WCF中不允许在协议中定义一个类型而传输其子类型. 除非在该类型上定义了[KnownType(typeof(子类型))]

2、WCF传输List<object>时序列化问题

WCF传输List集合时,在序列化时是有大小限制的,默认的可序列化的集合长度是65536,如果List的大小超出这个值就需要更改了配置了,在服务器端的behavior配置中增加一行配置

<behavior name="WCFService.Behavior">
          <serviceMetadata/>
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>

并且在对应的binding配置中添加readerQuotas节点配置


        <binding name="BasicWsHttpBinding">
          <reliableSession enabled="true" />
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="None" />
          </security>
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>

0 0