【问题标题】:Problem with large requests in WCFWCF 中的大请求问题
【发布时间】:2011-11-20 04:41:51
【问题描述】:

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

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

格式化程序在尝试反序列化 消息:尝试反序列化参数时出错 http://BlanketImportService.ServiceContracts/2011/06:request。这 InnerException 消息是“反序列化 BlanketImport.BlanketImportRequest 类型的对象。最大数组 读取 XML 数据时已超出长度配额 (16384)。这 可以通过更改 MaxArrayLength 属性来增加配额 创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象。 第 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>

【问题讨论】:

  • 服务名称只是“BlanketImport”,还是在命名空间下(如BlanketImport.BlanketImport)? &lt;service&gt; 元素的“name”属性的值必须是服务的fully-qualified-name(命名空间+类型名称),否则WCF 将找不到它。
  • 现在是 2015 年,wcf 配置设置对我们大多数人来说仍然是个谜。

标签: wcf binding basichttpbinding


【解决方案1】:

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

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

【讨论】:

  • 太好了 - 如果您将自己的答案标记为解决方案,您将获得徽章。 :)
【解决方案2】:

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

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

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

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多