首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF服务编程需要专家咨询

WCF服务编程需要专家咨询
EN

Stack Overflow用户
提问于 2013-05-14 17:55:24
回答 1查看 355关注 0票数 0

-如果这个帖子和其他一些帖子是多余的,那么我很抱歉,但是我的项目的问题似乎是我的架构造成的,所以我需要一般的帮助。-!

我正在尝试配置一个连接到Silverlight 5客户端的WCF服务和一个执行CRUD请求的C#类库。这项服务将需要传递大量的数据。例如,我的服务类中有一个公共IList< RainRecord> GetAllRain()方法,它可以在数据库中检索几十万条记录,将来可能会更多。所以我想我可以通过更小的批次获得所有这些记录(我认为这是一个非常好的方法)。

这是我的web.config文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>

<!--This file contains the web configuration used by the WCF service. -->

<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" maxBatchGeneratedFileSize="2147483647" maxBatchSize="2147483647" />
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>

  <system.serviceModel>

   <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
     <serviceActivations>
       <add service="PoseidonServiceNamespace.PoseidonService" relativeAddress="~/PoseidonService.svc"/>
     </serviceActivations>
   </serviceHostingEnvironment>

    <bindings>
      <basicHttpBinding>
        <binding  closeTimeout="00:01:00"
                  openTimeout="00:01:00"
                  receiveTimeout="00:10:00"
                  sendTimeout="00:01:00"
                  allowCookies="false"
                  bypassProxyOnLocal="false"
                  hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="2147483647"
                  maxBufferPoolSize="2147483647"
                  maxReceivedMessageSize="2147483647"
                  messageEncoding="Text"
                  textEncoding="utf-8"
                  transferMode="Buffered"
                  useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport  clientCredentialType="None"
                        proxyCredentialType="None"
                        realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="PoseidonServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>



    <services>
      <service  behaviorConfiguration="PoseidonServiceBehavior"
                name="PoseidonServiceNamespace.PoseidonService">
        <endpoint address="http://localhost:49455/PoseidonService.svc"
                  binding="basicHttpBinding"
                  contract="PoseidonServiceNamespace.IPoseidonService"/>

        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>

 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

我应该在这个文件中做什么更改(为什么?),我应该如何在我的服务中实现我的公共IList GetAllRain()方法?

真的非常感谢你,我已经花了很长时间在这个上面了

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-14 18:42:46

您确定需要将数十万条记录传输到客户端应用程序吗?客户如何查看这些记录?这些记录是以某种方式进行预处理/聚合,还是仅仅显示在某个网格中?如果预处理-考虑在服务器端进行预处理。如果只是显示-考虑重新设计您的接口,以包括分页:

代码语言:javascript
复制
IList<RainRecord> GetList(int startPage, int pageSize);

如果分页不是一个选项,但您仍然希望分批检索数据--您可以通过在服务中引入状态来实现手动批处理(您需要知道请求的列表是谁,您目前在哪个位置,以及还有多少数据需要传输):

代码语言:javascript
复制
public interface IService
{
  Guid BeginGetList();
  IList<RainRecord> GetNextBatch(Guid id);
}

GetNextBatch返回的空列表或null将指示传输结束。换句话说,它是相同的分页,但使用有状态服务实现。

现在,如果转移数十万条记录是绝对必要的,并且必须作为一个调用来完成--请考虑使用流传输数据。但是您需要更改您的合同,以便包含带有序列化RainRecords的Stream。

另一种选择是实现双工业务,后者将向客户端传递回调,并且当客户端完成前一批处理后,它可以请求下一步。这样做的缺点是据我所知,silverlight不支持WSDualHttpBinding。

有了绑定您的附件,您将被限制在每批2Gb,我认为这是足够的。另外,您可能需要调整超时,这个职位非常详细地描述了所有可能的超时值。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16549716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档