Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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]
Posted
Updated 21-Jan-14 23:32pm
v2

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900