如何通过WCF将记录集从服务器传输到客户端? [英] How can I transfer a recordset from Server to Client through WCF?
本文介绍了如何通过WCF将记录集从服务器传输到客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过WCF将记录集从服务器传输到客户端?
这是客户端应用程序想要的场景
,例如,找到与搜索词的LIKE模式匹配的记录,它将其发送到WCF服务,该服务找到匹配的记录并发回所有列和行。如果有人能帮助我,我将非常感激。 [特别是在VB.net]
How can I transfer a recordset from Server to Client through WCF?
Here is the scenario
Client application wants, for example, find the records which match the LIKE pattern for a search term, it sends it to a WCF service, the service find the matching records and sends back all columns and rows. I'll be very thankful if anyone would help me. [Specially in VB.net]
推荐答案
试试这个
经过大量调查后我得到了解决方案。实际上有很多事情需要改变。
需要在服务器端进行以下更改。
首先,我必须在我的httpRuntime元素中将maxRequestLength设置为更大的值,以便在更长的时间内运行请求。
< system.web>
< httpruntime maxrequestlength =102400>
第二我介绍了netTcpBinding合并以及maxBufferSize,maxBufferPoolSize,maxReceivedMessageSize上的自定义更改大值2147483647.
< binding name =myNetTcpBinding>
maxBufferPoolSize =2147483647
maxBufferSize =524288
maxReceivedMessageSize =2147483647>
第三次在bellow中添加serviceBehaviors和endpointBehaviors的maxItemsInObjectGraph(别忘了提及行为名称)在服务和端点节点中)
< behavior>
< servicebehaviors>
< behavior name =myNetTcpBehaviour>
< servicemetadata httpgetenabled =true>
< servicedebug includeexceptiondetailinfaults = true>
< datacontractserializer maxitemsinobjectgraph =2147483647>
< endpointbehaviors>
< behavior name =myNetTcpEndPointBehaviour>
< datacontractserializer maxitemsinobjectgraph =2147483647>
最后我的服务器配置如下所示
< system.web>
< httpruntime maxrequestlength =102400>
< system.servicemodel>
<绑定>
< wshttpbinding>
< binding name =MyWsHttpBinding>
< nettcpbinding>
< binding name =myNetTcpBinding>
closeTimeout =00:01:00
openTimeout =00: 01:00
receiveTimeout =00:10:00
sendTimeout =00:01:00
transactionFlow =false
transferMode =缓冲
transactionProtocol =OleTransactions
hostNameComparisonMode =StrongWildcard
listenBacklog = 10
maxBufferPoolSize =2147483647
maxBufferSize =524288
maxConnect ions =10
maxReceivedMessageSize =2147483647>
< readerquotas maxdepth =32>
maxStringContentLength =8192
maxArrayLength =16384
maxBytesPerRead =4096
maxNameTableCharCount =16384/>
< reliablesession ordered =true>
inactivityTimeout =00:10:00
enabled =false/>
< security mode =Transport>
< transport clientcredentialtype =Windowsprotectionlevel =EncryptAndSign>
< services>
< service name = AdminServicebehaviorconfiguration =myNetTcpBehaviour>
< endpoint address =AdminSrv>
binding =netTcpBinding
bindingConfiguration = myNetTcpBinding
contract =IAdminService
behaviorConfiguration =myNetTcpEndPointBehaviour/>
< endpoint address =mexbinding =mexHttpBindingcontract =IMetadataExchange>
< host>
< baseaddresses>
< add baseaddress =/ Bus / IRfotoWCF>
< / baseaddresses>
< behavior>
< servicebehaviors>
< behavior name =myNetTcpBehaviour>
< servicemetadata httpgetenabled =true>
< servicedebug includeexceptiondetailinfaults = true>
< datacontractserializer maxitemsinobjectgraph =2147483647>
< endpointbehaviors>
< behavior name =myNetTcpEndPointBehaviour>
< datacontractserializer maxitemsinobjectgraph =2147483647>
< servicehostingenvironment multiplesitebindingsenabled =true>
现在在客户端配置你需要更改maxBufferSize =2147483647maxBufferPoolSize =524288maxReceivedMessageSize =2147483647
你还需要在端点中添加maxItemsInObjectGraph =2147483647行为配置。
&l t; endpointbehaviors>
< behavior name =myEndPointBehavior>
< datacontractserializer maxitemsinobjectgraph =2147483647>
现在我可以在5.30分钟内传输30000行,查询执行时间为10秒,因此传输时间为5.20分钟 - 仍然很多。
随意评论和任何改进建议。
Try this
After a lot of investigation finnally i got the solution. Actually a number of things need to be changed.
The following changes needed to be done in Server-side.
First I had to set a maxRequestLength to a larger value in my httpRuntime element to run the request for longer period.
<system.web>
<httpruntime maxrequestlength="102400">
Second i introduced netTcpBinding binnding with custom changes on maxBufferSize, maxBufferPoolSize, maxReceivedMessageSize with a large value of 2147483647.
<binding name="myNetTcpBinding">
maxBufferPoolSize="2147483647"
maxBufferSize="524288"
maxReceivedMessageSize="2147483647">
Third add maxItemsInObjectGraph in both of the serviceBehaviors and endpointBehaviors like bellow (dont forget to mention the behaviour names in the service and endpoint node)
<behaviors>
<servicebehaviors>
<behavior name="myNetTcpBehaviour">
<servicemetadata httpgetenabled="true">
<servicedebug includeexceptiondetailinfaults="true">
<datacontractserializer maxitemsinobjectgraph="2147483647">
<endpointbehaviors>
<behavior name="myNetTcpEndPointBehaviour">
<datacontractserializer maxitemsinobjectgraph="2147483647">
Finally my server configuration looks like this
<system.web>
<httpruntime maxrequestlength="102400">
<system.servicemodel>
<bindings>
<wshttpbinding>
<binding name="MyWsHttpBinding">
<nettcpbinding>
<binding name="myNetTcpBinding">
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="2147483647"
maxBufferSize="524288"
maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerquotas maxdepth="32">
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliablesession ordered="true">
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientcredentialtype="Windows" protectionlevel="EncryptAndSign">
<services>
<service name="AdminService" behaviorconfiguration="myNetTcpBehaviour">
<endpoint address="AdminSrv">
binding="netTcpBinding"
bindingConfiguration="myNetTcpBinding"
contract="IAdminService"
behaviorConfiguration="myNetTcpEndPointBehaviour"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
<host>
<baseaddresses>
<add baseaddress="/Bus/IRfotoWCF">
</baseaddresses>
<behaviors>
<servicebehaviors>
<behavior name="myNetTcpBehaviour">
<servicemetadata httpgetenabled="true">
<servicedebug includeexceptiondetailinfaults="true">
<datacontractserializer maxitemsinobjectgraph="2147483647">
<endpointbehaviors>
<behavior name="myNetTcpEndPointBehaviour">
<datacontractserializer maxitemsinobjectgraph="2147483647">
<servicehostingenvironment multiplesitebindingsenabled="true">
Now on the client-side configuratioin you need to change the maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
and also you need to add maxItemsInObjectGraph="2147483647" in endpoint behaviour configuration.
<endpointbehaviors>
<behavior name="myEndPointBehavior">
<datacontractserializer maxitemsinobjectgraph="2147483647">
Now i can transmit 30000 rows within 5.30 min where the query executed for 10 sec so the transmission time is 5.20 min - still a lot.
Feel free to comment and any suggestion for improvement.
这篇关于如何通过WCF将记录集从服务器传输到客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文