9

我已经看到这个问题发布了一百万次,但没有一个解决方案对我有用......所以我开始了:

调用 WCF 服务时出现以下错误:

格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数 http://BlanketImportService.ServiceContracts/2011/06:request时出错。InnerException 消息是“反序列化 BlanketImport.BlanketImportRequest 类型的对象时出错。读取 XML 数据时已超出最大数组长度配额 (16384)。可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性来增加此配额。第 1 行,位置 44440.'。有关更多详细信息,请参阅 InnerException。

readerQuotas在两个客户端服务器上都修改了,并应用了 bindingConfiguration 标记。

这是服务器配置:

<bindings>
  <basicHttpBinding>
    <binding name="BilagImportBinding" maxBufferSize="2147483647"
      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="BlanketImport">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BilagImportBinding" bindingNamespace="http://BlanketImportService.ServiceContracts/2011/06" contract="BlanketImport.IBlanketImport">
    </endpoint>
  </service>
</services>

和客户端配置:

  <bindings>
    <basicHttpBinding>
      <binding name="BilagImportBinding" maxBufferSize="2147483647"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost/BlanketImport/BlanketService.svc"
      binding="basicHttpBinding" bindingConfiguration="BilagImportBinding" contract="BlanketServiceReference.IBlanketService"
      name="BasicHttpBinding_IBlanketService" />
  </client>
4

3 回答 3

20

找到了解决办法……但还是很奇怪!

如果我从绑定标签中删除 name 属性并从端点标签中删除 bindingConfiguration 属性,则一切正常。这意味着 basicHttpBinding 配置是所有 basicHttpBinding 端点的默认配置

于 2011-09-20T08:07:22.067 回答
2

我在尝试使用命名绑定配置使用 WCF 上传文件时遇到了同样的问题。这与 WCF 4.0 和“简化”配置中的更改有关(请参阅MSDN

仅供参考:我尽一切努力解决这个问题;服务的参数是一个字节数组,所以我们删除了它并使用了一个流,尝试更改缓冲模式与流模式,显然还有 150 万个配置选项来更改从未使用命名配置获取的大小。

确实很奇怪,但是按照您的建议工作。

于 2012-02-01T03:11:27.253 回答
0

我有一个类似的问题,端点没有使用命名绑定。我的问题是服务名称中的拼写错误。就像 Livewire 所说,WCF 4 Simplified Configuration 会自动创建一个端点,而我定义的端点并没有覆盖它。

于 2014-02-21T19:23:51.757 回答