问题描述
我已经创建了一个WCF的服务,一个W2008-服务器上运行的操作,并返回一个数据结构作为结果。问题是,这个结果可以更大,比标准的服务配置似乎接受。于是,我就增加(或删除)这个最大大小,但现在看来,我没有找到正确的属性。
I have created an WCF-Service that runs an operation on a W2008-Server and returns a datastructure as a result. Problem is, that this result can be larger, than the standard service configuration seems to accept. So I tried to increase (or remove) this maximum size, but it seems, I didn't found the correct properties.
在WCF的App.config中,我改变了我的basicHttpBinding的以下值:
In the App.config of the WCF, I changed the following values of my basicHttpBinding:
- MaxBufferPoolSize - > 6553600
- MAXBUFFERSIZE - > 6553600
- MaxReceiveMessageSize - > 6553600
ReaderQuotas:
ReaderQuotas:
- MaxArrayLenght - > 0
- MaxBytesPerRead - > 0
- MAXDEPTH - > 0
- MaxNameTableCharCount - > 0
- MaxStringContentLength - > 0
- MaxArrayLenght -> 0
- MaxBytesPerRead -> 0
- MaxDepth -> 0
- MaxNameTableCharCount -> 0
- MaxStringContentLength -> 0
我然后启动WCF的TestClient的调用服务。我保证,这为basicHttpBinding的属性的值等于在配置的人。当我调用服务的方式,结果集是相当小的,一切工作正常。但是,当这种规模的增加,我终于得到错误(德国翻译):
I then start the WCF-Testclient to call the service. I make sure, that the values for the properties of the basicHttpBinding are equal to the ones in the configuration. When I call the service in a way, that the result set is rather small, everything works fine. But when this size is increased, I eventually get the error (translated from german):
错误而接收HTTP答案的。可能的原因:Endpointbinding不使用HTTP协议或HTTP-的RequestContext已被服务器取消
服务器堆栈跟踪:
在System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(引发WebException引发WebException,HttpWebRequest的要求,HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
在System.ServiceModel.Channels.HttpChannelFactory。 HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度超时)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
在System.ServiceModel.Channels.RequestChannel.Request(消息消息,时间跨度超时)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,时间跨度超时)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串行动,布尔单向,ProxyOperationRuntime操作,对象[]项,在System.ServiceModel.Channels.ServiceChannel.Call对象[]奏,时间跨度超时)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
(串动,布尔单向,ProxyOperationRuntime操作,对象[]项,对象[]奏)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天消息)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
我想配置服务,无论大小的返回结果。事先有人知道,在这里我需要改变配置?
I would like to configure the service to return the result regardless of the size. Anybody knows, where I need to change the configuration?
谢谢,
弗兰克
Thanks in advance,Frank
推荐答案
如果您有大量的正在序列化对象的,WCF将达到配置的限制和BARF。你已经尝试了所有的标准的项目,但有一个你离开了: maxItemsInObjectGraph
。就像其他的配置值,则需要将其设置了服务器端的和的客户端。下面是用不必要的大值的样本配置SNIPPIT:
If you have a large number of objects that are being serialized, WCF will hit a configured limit and barf. You've tried all the standard items, but there's one you left out: maxItemsInObjectGraph
. Just like other config values, you'll need to set it both server-side and client-side. Here's a sample config snippit with an unnecessarily large value:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
我显然忽略了很多的标签有利于图示,其中 maxItemsInObjectGraph
出现在您的config文件。
I'm obviously omitting a lot of tags in favor of illustrating where maxItemsInObjectGraph
appears in your .config file.
这篇关于删除WCF的服务解答大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!