2013-04-05 129 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