想要从WCF服务返回大量数据 [英] Want to return huge data from WCF services

查看:107
本文介绍了想要从WCF服务返回大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨开发者,



我正在使用WCF服务从数据库中检索数据。它返回大约30000行的行数,将来它必须大于30000行。





请帮我解决问题或如何解决WCF服务中的数据问题。



我尝试了什么:



在应用程序web.config中我设置了以下提及的设置,

 <   system.servicemodel  >  
< bindings < span class =code-keyword>>
< basichttpbinding >
< binding name = BasicHttpBinding_SampleService closetimeout = 00:11:00 opentimeout = 00:11:00 receivetimeout = 00:10:00 sendtimeout = 00:11:00 allowcookies = false bypassproxyonlocal = false maxbufferpoolsize = 2147483647 maxreceivedmessagesize = 2147483647 usedefaultwebproxy = true transfermode = 流式 / >
< < span class =code-leadattribute> / basichttpbinding >
< / bin dings >
< 客户 >
< 端点 地址 = http:// localhost:61920 / Service / SampleServic.svc > binding =basicHttpBinding bindingConfiguration =BasicHttpBinding_ISampleServiccontract =ISampleServicname =BasicHttpBinding_ISampleServic& gt ;;
< / endpoint >
< / client >
< / system.servicemodel >



和服务web.config配置如下设置

 <   system.servicemodel  >  
< bindings >
< basichttpbinding >
< 绑定 maxbuffersize = 2147483647 maxreceivedmessagesize = 2147483647 >
< readerquotas maxstringcontentlength = 2147483647 maxarraylength = 2147483647 maxbytesperread = 4096\" maxnametablecharcount = 2147483647 / >
< / binding >
< / basichttpbinding >
< / bindings >
< 行为 < span class =code-keyword>>
< servicebehaviors >
< ; 行为 >
< servicemetadata httpgetenabled = true httpsgetenabled = false / >
< servicedebug includeexceptiondetailinfaults = true / >
< datacontractserializer maxitemsinobjectgraph = 2147483646 / >
< / behavior >
< / servicebehaviors >
< / behavior >
< protocolmapping >
< add binding = basicHttpBinding scheme = http / >
< / protocolmapping >
< ; servicehostingenvironment aspnetcompatibilityenabled < span class =code-keyword> = true multiplesitebindingsenabled <温泉n class =code-keyword> = true / >
< / system.servicemodel >
< system.webserver >
< modules runallmanagedmodulesforallrequests = true / >
< directorybrowse 已启用 = false / >
< ; / system.webserver >

解决方案

错误的方式。

您必须改变应用程序的组织方式。



30000行需要花费大量时间从数据库中进行检索,并且构建网格需要花费大量时间。在一个网格中有人真正使用30000行的可能性很小。



您必须改变应用程序的行为方式,您可能需要在具有有限记录的页面中剪切网格并添加页面导航系统并且可以搜索按钮/字段。网格大小不超过一对屏幕尺寸,一次大约50行。



用户应用响应式应用程序。

您需要提供更多有关用法的详细信息以获得更多解释。


错误,错误,错误!



用户从不想看30,000行。天啊,我甚至不喜欢看20行。



设置网格进行分页。您只需要显示少量行。网格显示的每个页面都应该生成对WCF服务的请求,该请求将仅返回该行数。在LINQ中,它很容易。你跳过RowsPerPage *(PageRequested - 1)的数量并获取下一行的RowsPerPage行数。



在LINQ中,使用Skip()和Take非常容易()方法。


您好,



感谢您的建议。



我得到了解决方案,

将[XmlSerializerFormat]属性应用于服务界面



例如:



[ServiceContract]

[XmlSerializerFormat]



公共接口ISampleService

{

[OperationContract]

DataTable GetSampleData(字符串s_PageName,字符串s_L10_UI);



[ OperationContract]

SampleCRUDProperties CRUDSampleOperations(SampleProperties sampleProperties)

}



将[XmlSerializerFormat]属性添加到界面后,我收到了从WCF服务到应用程序的响应

Hi Developers,

I am using WCF services for retrieve data from the database. It returns near about 30000 number of rows and in future it must be grater than 30000 rows.


Please help me how to resolve issue or any another approach to retrieve data from the WCF services.

What I have tried:

In application web.config i have set below mention settings,

<system.servicemodel>   
	<bindings>
      <basichttpbinding>
        <binding name="BasicHttpBinding_SampleService" closetimeout="00:11:00" opentimeout="00:11:00" receivetimeout="00:10:00" sendtimeout="00:11:00" allowcookies="false" bypassproxyonlocal="false" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647" usedefaultwebproxy="true" transfermode="Streamed" />        
      </basichttpbinding>        
	</bindings>
    <client>
      <endpoint address="http://localhost:61920/Service/SampleServic.svc"> binding="basicHttpBinding"  bindingConfiguration="BasicHttpBinding_ISampleServic" contract="ISampleServic" name="BasicHttpBinding_ISampleServic" &gt;;      
    </endpoint>
	</client>   
</system.servicemodel>  


and in services web.config configuration as per below settings

<system.servicemodel>
<bindings>
  <basichttpbinding>
	<binding maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
	  <readerquotas maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="4096" maxnametablecharcount="2147483647" />
	</binding>
  </basichttpbinding>
</bindings>
<behaviors>
  <servicebehaviors>
	<behavior>
	  <servicemetadata httpgetenabled="true" httpsgetenabled="false" />
	  <servicedebug includeexceptiondetailinfaults="true" />
	  <datacontractserializer maxitemsinobjectgraph="2147483646" />
	</behavior>
  </servicebehaviors>
</behaviors>
<protocolmapping>
  <add binding="basicHttpBinding" scheme="http" />
</protocolmapping>
<servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />
</system.servicemodel>
<system.webserver>
<modules runallmanagedmodulesforallrequests="true" />
<directorybrowse enabled="false" />
</system.webserver>

解决方案

Wrong way.
You have to change the way your app is organized.

30000 rows takes huge time to retreive from database, and it takes huge time to build the grid. There is also very little chances that someone ever have real usage of the 30000 rows in a single grid.

You have to change how your app behave, you probably need to cut the grid in pages with limited records and add a page navigation system and may some search button/field. the grid size will be no more than a couple screen size in height, say about 50 rows at a time.

Users apprciate responsive apps.
You need to provide more details about the usage for more explantions.


Wrong, wrong, WRONG!

Users NEVER want to look at 30,000 rows. Hell, I don't even like looking at 20 rows.

Setup your grid for paging. You only need to show a small number of rows. Each page the grid shows should generate a request to the WCF service that will return just that number of rows. In LINQ, it's easy. You skip the number of RowsPerPage * (PageRequested - 1) and grab the next RowsPerPage number of rows.

In LINQ, that's very easy with the Skip() and Take() methods.


Hi,

Thanks for your suggestion.

I got the solution,
applying the [XmlSerializerFormat] attribute to the services interface

for Example:

[ServiceContract]
[XmlSerializerFormat]

public interface ISampleService
{
[OperationContract]
DataTable GetSampleData(string s_PageName, string s_L10_UI);

[OperationContract]
SampleCRUDProperties CRUDSampleOperations(SampleProperties sampleProperties)
}

After adding [XmlSerializerFormat] attribute to interface, i have getting response from the WCF Services to Application


这篇关于想要从WCF服务返回大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆