【发布时间】:2014-12-17 12:36:12
【问题描述】:
我已经创建了 WCF 和 Web Api REST 完整的 Web 服务。在这个网络服务中,我得到了
用于大数据传输。
EX:在这种情况下,我有 25 列和 25000 行的 fetch 查询,有时数据来了,有时
这两个错误都会出现。 我的 WCF 配置。像这样
那么任何人都可以建议我。
【问题讨论】:
标签: wcf c#-4.0 asp.net-web-api
我已经创建了 WCF 和 Web Api REST 完整的 Web 服务。在这个网络服务中,我得到了
用于大数据传输。
EX:在这种情况下,我有 25 列和 25000 行的 fetch 查询,有时数据来了,有时
这两个错误都会出现。 我的 WCF 配置。像这样
那么任何人都可以建议我。
【问题讨论】:
标签: wcf c#-4.0 asp.net-web-api
尝试在 web config reader quoata 中设置绑定 对于大传输,defualt 小
详情:http://msdn.microsoft.com/en-us/library/ms731325(v=vs.110).aspx
例子
<binding name="myLargeBinding" 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" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxArrayLength="2147483647"/>
</binding>
然后不要忘记将此 bindningConfiguration 设置为端点
<endpoint .... binding="basicHttpBinding" bindingConfiguration="myLargeBinding" .... >
对于您的 web.config,它应该是这样的。
我创建了新的绑定配置“RESTBinding”并将其设置到您的端点。
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime maxRequestLength ="1048576"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"></serviceHostingEnvironment>
<services>
<service behaviorConfiguration="" name="wcfTestHC.TestHC">
<endpoint address="" behaviorConfiguration="RestEndpointBehavior" binding="webHttpBinding" bindingConfiguration="RESTBinding" contract="wcfTestHC.ITestHC" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestEndpointBehavior">
<webHttp helpEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
<serviceThrottling maxConcurrentCalls="250" maxConcurrentInstances="75" maxConcurrentSessions="50"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RESTBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxArrayLength="2147483647"/>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="EndpointBehavior" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxArrayLength="2147483647"/>
<reliableSession enabled="True" ordered ="True "/>
</binding>
</wsHttpBinding>
</bindings>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
</diagnostics>
</system.serviceModel>
<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="4"/>
</switches>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\WCFLoging.svclog" />
</sharedListeners>
</system.diagnostics>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength ="1073741824"></requestLimits>
</requestFiltering>
</security>
</system.webServer>
</configuration>
如果您仍然遇到错误。也许问题出在其他地方。 尝试将这些设置插入您的 web.config。这将为您的服务提供详细的日志记录和异常详细信息,我们将在那里查看问题所在。我已将日志的位置设置为 c:\temp\WCFLoging.svclog,如果需要,请更改它,并且我已经使用这些设置编辑了 web.config 的示例 - 准备好复制和粘贴 :-)
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
</diagnostics>
</system.serviceModel>
和
<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="4"/>
</switches>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\WCFLoging.svclog" />
</sharedListeners>
</system.diagnostics>
【讨论】:
maxBufferSize="2147483647" transferMode="Buffered" 这样的选项。我正在使用 4.5 框架。你能建议我吗?