我创建了一个与我的应用程序c#相关的webService。
所有方法都运行良好。但是,函数存在“ TimeOut ”问题。 这个方法应该返回一个整数数组,大约有[1,000,000] (100万)整数。 在调用我的方法后,我正确地获得了数据,但是 4-5分钟! 表1百万整数等待大约5分钟是否正常? 我发现它可能需要太长时间并且对我的应用程序很烦人。 您是否知道发送大数据的解决方案或更好的方法?
这是我在服务器端的配置文件:
的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>
答案 0 :(得分:1)
我认为您应该尝试对结果进行分页,以便为每个请求带来更少的数据。
答案 1 :(得分:1)
最简单的解决方案是对结果进行分页:设置一个可以由WCF服务返回的整数限制(例如2000),并调用它直到响应包含0数字。
答案 2 :(得分:1)
如果您的服务和客户端在同一台PC上运行,请尝试使用net.pipe绑定,如果没有 - 请尝试使用net.tcp绑定。
答案 3 :(得分:0)
下午好。 最后,正确的解决方案是改变编码模式! 实际上,默认[WCF]发送响应格式“xml”全文。这非常沉重! 设计了一个整数数组。对于每个索引/值[WCF]标记将以格式添加不必要的文本: 实例
<强> XML 强>
<!-- Too heavy with text / tag useless for the customer -->
<xmlns blabalala ......... />
<item>11</item>
<item>2</item>
<item>41</item>
.....
简单的二进制格式/或Json 轻得多......等等:
11,2,41,2,6,7,34,8,43,12,76, .....
无论如何我终于改变了传输二进制的方法!一个页面,它帮助我很多选择编码方法,并发送流媒体或其他!
微软在这里的文章 - &gt; Large Data and Streaming - WCF
不时变化! ~3min - ~3min 30sec - ~4min ... 但它已经好一点了。我想不幸的是,没有其他方法可以更快地使用[WCF],否则使用“WebSocket”将是最好的解决方案。 对于我的应用程序,我挂着使用[wcf] .. 我认为我的方法添加webService访问模式“async”以允许在我下载期间添加progressBar。 欢迎其他想法; - )