删除WCF服务答案的大小限制

我创建了一个WCF服务,它在W2008-Server上运行一个操作并返回一个数据结构。 问题是,这个结果可能比标准服务配置似乎更接受。 所以我试图增加(或删除)这个最大尺寸,但似乎,我没有找到正确的属性。

在WCF的App.config中,我更改了basicHttpBinding的以下值:

  • MaxBufferPoolSize – > 6553600
  • MaxBufferSize – > 6553600
  • MaxReceiveMessageSize – > 6553600

ReaderQuotas:

  • MaxArrayLenght – > 0
  • MaxBytesPerRead – > 0
  • MaxDepth – > 0
  • MaxNameTableCharCount – > 0
  • MaxStringContentLength – > 0

然后我启动WCF-Testclient来调用该服务。 我确保basicHttpBinding的属性值等于配置中的值。 当我以某种方式调用服务时,结果集相当小,一切正常。 但是当这个尺寸增加时,我最终会得到错误(翻译自德语):

接收http :// localhost:8731 / Design_Time_Addresses / DiscoDataSource / Service1 /的 http应答时出错。 可能的原因:Endpointbinding不使用HTTP协议,或者服务器取消了HTTP-requestcontext。

服务器堆栈跟踪:

在System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException,HttpWebRequest request,HttpAbortReason abortReason)

at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)

在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)

在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)

在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs)

在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)

在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

我想配置服务以返回结果,无论大小。 谁知道,我需要在哪里更改配置?

谢谢,弗兰克

如果您有大量正在序列化的对象,WCF将达到配置的限制和barf。 你已经尝试了所有的标准项目,但是你遗漏了一个: maxItemsInObjectGraph 。 就像其他配置值一样,您需要在服务器端客户端设置它。 这是一个带有不必要的大值的示例配置snippit:

               

我显然省略了很多标签,有利于说明你的.config文件中出现maxItemsInObjectGraph

您是否也在客户端和服务器端更改了这些值? 你需要在通信的两端改变它们 – 只有它才能起作用。

如果您没有在服务器端更改它们,则较小的值(客户端和服务器值)将“赢”。

但是,可能只是你的超时设置导致服务器中止。 在你的绑定上,你可以调整超时 – 默认情况下,它是60秒 – 所以如果抓取数据并根据需要组装它需要更多的时间,你需要调整绑定上的SendTimeout ,而不是大小设置.. …