【问题标题】:Why WCF formatter is throwing an exception?为什么 WCF 格式化程序会引发异常?
【发布时间】:2009-04-30 02:56:39
【问题描述】:

在调用 WCF 服务时收到以下错误消息:

“格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:fieldText时出错。InnerException消息是'反序列化System.String []类型的对象时出错。读取 XML 数据时已超出最大字符串内容长度配额 (8192)。可通过更改创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性来增加此配额。第 1 行,位置 10889。'。有关更多信息,请参阅 InnerException详情。”

我的 web.config 中的 WCF 部分如下所示:

<basicHttpBinding>
        <binding name="BasicHttpBinding_IMySvc" maxReceivedMessageSize="2147483647" sendTimeout="00:05:00"
                 messageEncoding="Text" textEncoding="utf-8" >
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="163840000"/>
        </binding>
</basicHttpBinding>

另外,我输入消息的大小是:15869 个字符。

我在这里错过了什么?

【问题讨论】:

  • 为清楚起见添加您的端点配置。
  • localhost:3193/MySvc.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMySvc" contract="MySvc.IMySvc" name="BasicHttpBinding_IMySvc" />

标签: wcf web-services


【解决方案1】:

确保您的端点确实在使用绑定。

<endpoint address="" binding="basicHttpBinding" contract="IMySvc" bindingConfiguration="BasicHttpBinding_IMySvc">

【讨论】:

  • 是的 - 只是声明它并没有真正帮助 - 它也必须被引用:-)
  • 当然可以...!否则它会抛出异常:在 ServiceModel 客户端配置部分中找不到引用合同“MySvc.IMySvc”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此协定匹配的端点元素。
猜你喜欢
  • 2014-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多