WCF サービスからデータを取得して Web サイトに表示しようとしています。
通信は次のようになります:
Web サイト --> WCF サービス --> CRM サーバー --> WCF サービス --> Web サイト
今私の問題は、取得するデータが大きく、約5k行になる場合があることです。(そして私のホスト PC は RAM を使い果たします) 1 ~ 10 行を Web サイトにストリーミングし、次に次の行をストリーミングしたいと考えています。
私の ServiceContract は次のようになります。
public interface ICommunicationService
{
[OperationContract]
IEnumerable<Row> GetCrmData(string view);
}
そして私の実装:
public IEnumerable<Row> GetCrmData(string view)
{
var data = new DataFromCrm(view);
return data.GetRows(MetaInformation);
}
GetRows メソッドは次のようになります: http://msdn.microsoft.com/en-us/library/gg327917.aspx foreach を除いて、Row クラスに値を入力し、結果を返します。(ページングとクッキングは無効になっています)。
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.イールド リターンは正しく使用されていますか?
バインディング
WCF サービス:
<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 クライアント
<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?