I'm trying to get data from a WCF Service and display it in a website.
The communication looks like this:
Website --> WCF service --> CRM Server --> WCF Service --> Website
Now my problem is, sometimes there are larger data to get, around 5k rows. (and my Host PC runs out of Ram) I want to stream 1-10 rows to the website then the next and so on.
My ServiceContract looks like this:
public interface ICommunicationService
{
[OperationContract]
IEnumerable<Row> GetCrmData(string view);
}
And my implementation:
public IEnumerable<Row> GetCrmData(string view)
{
var data = new DataFromCrm(view);
return data.GetRows(MetaInformation);
}
the GetRows method looks exactly like this: http://msdn.microsoft.com/en-us/library/gg327917.aspx except in the foreach I'm filling the Row class and yield returning the result. (paging and cooking is disabled atm).
foreach (var c in returnCollection.Entities)
{
var row = new Row();
row.RecordId = c.Attributes[ID].ToString();
foreach (var info in metaInfo)
{
row.Cells.Add(c.Attributes[info.AttributeName]);
}
yield return row;
}
1. Is the yield return used right?
Bindings
WCF Service:
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="ComToCrmService.CommunicationService">
<endpoint binding="basicHttpBinding"
bindingNamespace="http://localhost:9006/CommunicationService.svc"
contract="ComToCrmContracts.ICommunicationService" />
</service>
</services>
WCF Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICommunicationService"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536"
maxReceivedMessageSize="4294967294"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Streamed"
useDefaultWebProxy="true">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ICommunicationService"
contract="ComToCrmReference.ICommunicationService"
name="BasicHttpBinding_ICommunicationService"
address="http://dev11.meta10.com:9007/WCFTestService/CommunicationService.svc" />
</client>
</system.serviceModel>
2. Are the bindings correct?
3. Is there a failure in my thinking?
remember I'm trying to get 1-10 rows out of 5000 display them on the website, get the next 1-10 rows and so on.
there are only data no binary data or something similar.
4. is it even possible with just one request?