2013-04-05 110 views
4

我已经看到了这个问题,弹出几次,但没有真正明确的答案大量数据(因为是最有可能没有)......我有一个需要大约返回一个WCF服务来自SQL的14,000行数据按基于列表<>的数组排序。传递一个WCF服务

我服务的配置是这样的:

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IParts" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

我的客户端配置是这样的:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IParts" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/RasFuseService/Parts.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IParts" 
      contract="MyParts.IParts" name="BasicHttpBinding_IParts" /> 
    </client> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyServiceBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

东西是不正确的,因为我得到的错误:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetSurplusECMResult . The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.

虽然我明确将其最大INT分配MaxItemsInObjectGraph ...

我读过有关流媒体和寻呼,但是这真的太数据在单次返回?

+0

从用户的角度看上午想想吧我真的会一次超过200行数据?答案很可能不是。 – 2013-04-05 00:33:34

+0

返回的数据是什么要求,设计......这家公司想知道发生了什么(x)和(x)的日期之间出售... – devHead 2013-04-05 00:36:59

+0

<行为NAME = “CalculatorServiceBehavior”> 请注意,您也必须这样做在客户端上。看到这里(向下滚动答案):http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c85f3ed2-0b55-4375-af79-5926b6cc527c/ – MaxOvrdrv 2013-04-05 00:38:09

回答

3

找出来了(打耳机的前额) 我最终在客户端写了一个不正确的条目。对于客户端的正确语法应该是:

<behaviors> 
    <endpointBehaviors> 
     <behavior > 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 

<behaviors> 
    <serviceBehaviors> 
     <behavior> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 

现在返回和反序列化我的大阵没有抱怨...

0

我在我的WCF服务在同一时间返回原始表格数据,几兆字节的情况。

的XML序列化是坏的......很多元素和浪费的空间,并且也慢。在这种情况下,我处理了自己的响应代码,并将数据格式化为CSV数据。客户端生成,发送和解析的速度相当快。

我使用REST风格的WCF(这是ASP.NET WCF替换为REST之前),所以我就回来从我的WCF方法的流。

0

在您的客户端配置中,您的行为有一个名称,但您似乎并未使用该名称。请在某处使用名称或省略名称,以使您的行为成为服务配置中的默认行为。

+0

我做到了,它仍然给出了同样的错误 – devHead 2013-04-05 11:59:08