繁体   English   中英

仍无法通过WCF传输大量数据 - 还有什么问题?

[英]Still unable to transfer large amounts of data via WCF - what else is wrong?

我有一个问题,我正在尝试从我的WCF服务传输大量对象。 我必须将对象的传输限制为100,否则会出现某种通信错误。

我尝试了解决方案中的建议,在这里找到,但也许我错过了一些东西,因为我仍然得到错误。

这是我的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://www.mysite.com/MyService.svc的HTTP响应时发生错误。 这可能是由于服务端点绑定不使用HTTP协议。 这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭)。 请参阅服务器日志以获取更多详

关于这一点的奇怪之处在于,当我写这篇文章时,我通​​过将返回逻辑更改为190个对象来重试它,并且它有效。 重试了,但失败了。

这可能是一个改变一些IIS设置的问题?

对此有任何帮助将不胜感激。

谢谢。

您尚未在服务配置中声明任何端点,这意味着正在使用WCF默认端点模型

但是,您已命名绑定配置和行为,这意味着它们不会被默认端点拾取。 如果从绑定配置和行为中删除名称,则它们将成为默认设置,并将被默认端点选中

错误消息说:

...有关详细信息,请参阅服务器日志

我将首先在服务器上配置跟踪,如本MSDN文章中所述

你不能使用'流媒体'WCF绑定吗?

WCF和流媒体

您的绑定需要根据您的行为设置行为配置。

  <endpoint address="http://www.mysiate.com/MyService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFeederService"
    behaviorConfiguration="myEndPointBehavior" contract="FeederService.IFeederService" name="BasicHttpBinding_IFeederService" />
</client>   </system.serviceModel>

否则,不会使用图形设置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM