我有一个问题,我正在尝试从我的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设置的问题吗?
对此有任何帮助将不胜感激。
感谢。
答案 0 :(得分:1)
您尚未在服务配置中声明任何端点,这意味着正在使用WCF默认端点模型
但是,您已命名绑定配置和行为,这意味着它们不会被默认端点拾取。如果从绑定配置和行为中删除名称,那么它们将成为默认设置,并将被默认端点选中
答案 1 :(得分:1)
答案 2 :(得分:0)
你不能使用'流媒体'WCF绑定吗?
答案 3 :(得分:0)
您的绑定需要根据您的行为设置行为配置。
<endpoint address="http://www.mysiate.com/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFeederService"
behaviorConfiguration="myEndPointBehavior" contract="FeederService.IFeederService" name="BasicHttpBinding_IFeederService" />
</client> </system.serviceModel>
否则不会使用图表设置