WCF中大请求的问题

发布于 2024-12-05 19:54:05 字数 2218 浏览 0 评论 0原文

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

当调用 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>

I've seen this problem posted a million times, but none of the solutions have worked for me...So here I go:

When calling a WCF service I get the following error:

The formatter threw an exception while trying to deserialize the
message: There was an error while trying to deserialize parameter
http://BlanketImportService.ServiceContracts/2011/06:request. The
InnerException message was 'There was an error deserializing the
object of type BlanketImport.BlanketImportRequest. The maximum array
length quota (16384) has been exceeded while reading XML data. This
quota may be increased by changing the MaxArrayLength property on the
XmlDictionaryReaderQuotas object used when creating the XML reader.
Line 1, position 44440.'. Please see InnerException for more details.

I have modified the readerQuotas on both the client server, AND applied the bindingConfiguration tag.

Here's the server config:

<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>

And the client config:

  <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撑一把青伞 2024-12-12 19:54:05

找到了解决方案...但还是很奇怪!

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

Found the solution...But still very strange!

If I remove the name attribute from my binding tag and the bindingConfiguration attribute from my endpoint tag it all works. This means that the basicHttpBinding configuration is the default configuration for all basicHttpBinding endpoints

陪你到最终 2024-12-12 19:54:05

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

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

确实很奇怪,但正在考虑你的建议。

I had the same problem whilst trying to upload files using WCF using a named binding configuration. This has to do with the changes in WCF 4.0 and "Simplified" Configuration (see MSDN)

FYI: I tried everything to solve this problem; the parameter to the service was a byte array, so we removed it and used a stream, tried changing buffered versus streaming mode and obviously the 1.5 million config options to change sizes that never got picked up with a named config.

Very strange indeed, but working with your suggestion.

悲念泪 2024-12-12 19:54:05

我遇到了类似的问题,端点未使用命名绑定。我的问题是服务名称中的拼写错误。就像 Livewire 所说,WCF 4 简化配置会自动创建一个端点,并且我定义的端点不会覆盖它。

I had a similar issue where the named binding wasn't used by the endpoint. My problem was a typo in the service name. Like Livewire said, WCF 4 Simplified Configuration automatically creates a endpoint and my defined endpoint was not overwriting it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文