【发布时间】:2012-01-22 03:20:08
【问题描述】:
我遇到了一个问题,我试图从我的 WCF 服务传输大量对象。我必须将对象的传输限制为 100,否则会出现某种通信错误。
我尝试了解决方案中的建议,找到了here,但可能我遗漏了一些东西,因为我仍然收到错误消息。
这是我的 WCF 服务的 web.config 的底部:
<system.web>
<httpRuntime maxRequestLength="102400" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyWsHttpBinding" />
</wsHttpBinding>
<netTcpBinding>
<binding name="myNetTcpBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="2147483647"
maxBufferSize="524288"
maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="myNetTcpBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<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"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="myNetTcpEndPointBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
接下来,这里是使用 Web 服务的网站的 web.config 部分的下部:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFeederService" 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="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="55000" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="myEndPointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://www.mysiate.com/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFeederService"
contract="FeederService.IFeederService" name="BasicHttpBinding_IFeederService" />
</client> </system.serviceModel>
我得到的错误是:
接收到的 HTTP 响应时出错 http://www.mysite.com/MyService.svc。这可能是由于服务 端点绑定不使用 HTTP 协议。这也可能是由于 到被服务器中止的 HTTP 请求上下文(可能是由于 到服务关闭)。有关详细信息,请参阅服务器日志。
奇怪的是,在我写这篇文章的时候,我重试了它,将返回逻辑更改为 190 个对象,它成功了。重试,失败。
这可能是更改某些 IIS 设置的问题吗?
我们将不胜感激。
谢谢。
【问题讨论】:
-
this 怎么样?
-
这也可能有助于stackoverflow.com/questions/1281269/…。问题可能是由于 basichttpbinding 配置的大小限制。
-
你一共转账多少钱?
-
开启跟踪 - 这应该可以查明您的请求失败的原因
标签: c# wcf service large-data-volumes