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

Aag*_*nor 3 c# 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消息)

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

先谢谢你,弗兰克

Ran*_*pho 6

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

<system.serviceModel>
 <behaviors>
   <serviceBehaviors>
     <behavior name="ServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
     </behavior>
   </serviceBehaviors>
   <endpointBehaviors>
     <behavior name="ClientBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
     </behavior>
   </endpointBehaviors>
 </behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

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