c# - 使用 WCF Web 服务发送 1 个包含 100 万个整数的数组等于大超时?

标签 c# wcf web-services soap

我创建了一个与我的应用程序 C# 相关的 webService。

所有方法都非常有效。但是,函数有问题“TimeOut”。 此方法应返回一个整数数组,其中包含大约 [1,000,000] (100 万) 个整数。 我正确地获取了数据,但在调用我的方法后大约 4-5 分钟! 一个表 100 万个整数等待大约 5 分钟是否正常? 我发现这对我的应用程序来说可能会花费太长时间且烦人。 您知道发送大数据的解决方案或更好的方法吗?

  • 其他压缩方法?
  • 其他响应格式(xml、数组..)?

这是我在服务器端的配置文件:

Web.config

<?xml version="1.0"?>
<configuration>

  <system.web>
      <customErrors mode="Off"/>
      <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>

    <diagnostics performanceCounters="Default" />
    <bindings>
      <basicHttpBinding>
        <binding name="Elevation_ServiceSoap" closeTimeout="00:02:00" messageEncoding="Mtom"
          openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00"
          allowCookies="true" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
        <binding name="BasicHttpBinding_IGeocodeService" allowCookies="true"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
        <binding name="BasicHttpBinding_IImageryService" allowCookies="true"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>

    <client>
      <endpoint address="http://gisdata.usgs.gov/XMLWebServices2/Elevation_Service.asmx"
        binding="basicHttpBinding" bindingConfiguration="Elevation_ServiceSoap"
        contract="ElevationService.Elevation_ServiceSoap" name="Elevation_ServiceSoap" />
      <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
        contract="GeocodeService.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
      <endpoint address="http://dev.virtualearth.net/webservices/v1/imageryservice/imageryservice.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IImageryService"
        contract="ImageryService.IImageryService" name="BasicHttpBinding_IImageryService" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment - binaryHttp -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="10000000"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

这是我在客户端的配置文件:

App.config

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:02:00"
                    openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00"
                    allowCookies="true" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors >
            <serviceBehaviors>
                <behavior name="debug">
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <dataContractSerializer maxItemsInObjectGraph="10000000"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <client>
            <endpoint address="http://blalbloslblalbla/WebServiceArcadia_World_deploy/Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                contract="WebServiceArcadia_World.IService1" name="BasicHttpBinding_IService1" />
        </client>
        <services>
            <service name="WebServiceArcadia_World_deploy.IService1">

            </service>
        </services>
    </system.serviceModel>
    <system.web>
        <httpRuntime executionTimeout="90" maxRequestLength="1048576" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/>
    </system.web>
</configuration>

最佳答案

我认为您应该尝试对结果进行分页,以便为每个请求带来更少的数据。

关于c# - 使用 WCF Web 服务发送 1 个包含 100 万个整数的数组等于大超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15619443/

相关文章:

java - 在 Jetty Embedded 中一一处理请求

java - WebLogic javax.net.ssl.SSLHandshakeException

javascript - 从网络服务获取图像

c# - Random.Next() 在发生回绕之前有多少次迭代?

c# - MySqlConnection ADO.Net CPU 使用率高

c# - 如何在循环中添加SqlParameters?

c# - 找不到 wcf serviceActivations

c# - WCF 服务是否公开属性?

c# - 跟踪状态参数是什么

c# - WCF 服务器接受 TLS 1.0 连接