2011-09-19 81 views
8

我已经看到了这个问题发布了百万次,但没有任何解决方案都为我工作...所以我来到这里:问题与WCF的大型请求

当调用WCF服务我得到以下错误:

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.

我已经在客户端服务器上修改的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> 
+0

服务名称是“BlanketImport”,还是位于命名空间下(如BlanketImport.BlanketImport)? “”元素的“name”属性的值必须是服务的名称*名称空间+类型名称,否则WCF将无法找到它。 – carlosfigueira

+0

这是2015年,wcf配置设置仍然是我们大多数人的一个谜团。 – abhi

回答

18

找到了解决办法...不过还是很奇怪!

如果我从我的绑定标记中删除名称属性,并从我的端点标记中除去bindingConfiguration属性,它将全部有效。这意味着basicHttpBinding配置是所有basicHttpBinding端点的默认配置

+1

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

+0

感谢您的解决方案! WCF配置过于复杂 –

+0

我花了3天时间研究相同的问题,直到找到解决方案。谢谢!!! – Copeleto

2

我尝试使用WCF使用命名绑定配置上传文件时遇到了同样的问题。这与在WCF 4.0和“简化”配置的变化做(见MSDN

FYI:我想尽一切办法解决这个问题;该服务的参数是一个字节数组,因此我们移除了它并使用了一个流,试图改变缓冲模式与流模式,显然有150万个配置选项用来更改从未使用命名配置获取的大小。

确实非常奇怪,但与您的建议。

+0

为链接+1 –

0

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