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

发布于 2024-12-28 10:34:54 字数 5384 浏览 4 评论 0原文

我在尝试从 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 响应时发生错误 http://www.mysite.com/MyService.svc。这可能是由于服务 端点绑定不使用 HTTP 协议。这也可能是由于 HTTP 请求上下文被服务器中止(可能是由于 到服务关闭)。有关更多详细信息,请参阅服务器日志。

奇怪的是,当我写这篇文章时,我重试了,将返回逻辑更改为 190 个对象,结果成功了。重试了一下,还是失败了。

这可能是更改某些 IIS 设置的问题吗?

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

谢谢。

I have an issue where I'm trying to transfer a large number of objects from my WCF service. I have to limit transfer of objects to 100, otherwise there's some kind of communications error.

I tried the recommendations in the solution, found here, but maybe I'm missing something, as I am still getting the error.

Here is the bottom part of my WCF service's 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>

Next, here is the lower part of the web.config portion of the website that consumes the web service:

  <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>

The error I get is:

An error occurred while receiving the HTTP response to
http://www.mysite.com/MyService.svc. This could be due to the service
endpoint binding not using the HTTP protocol. This could also be due
to an HTTP request context being aborted by the server (possibly due
to the service shutting down). See server logs for more details.

The odd thing about this is that as I was writing this post, I retried it with changing the return logic to 190 objects, and it worked. Retried, and it failed.

Is this maybe a matter of changing some IIS settings?

Any assistance on this would be appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

薄荷梦 2025-01-04 10:34:54

错误消息显示:

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

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

The error message says:

... See server logs for more details.

I would start by configuring tracing on the server as described in this MSDN article.

杀お生予夺 2025-01-04 10:34:54

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

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

You haven't declared any endpoints in your service config which means the the WCF default endpoint model is being used

However, you have named your binding configurations and behaviors which means they do not get picked up by the default endpoints. If you remove the names from the binding configuration and behaviors then they will become default settings and will get picked up by the default endpoints

陪你搞怪i 2025-01-04 10:34:54

不能使用“流式”WCF 绑定吗?

WCF 和流媒体

Can't you use a 'Streamed' WCF binding ?

WCF & Streaming

忘东忘西忘不掉你 2025-01-04 10:34:54

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

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

否则将不会使用图形设置

Your binding needs to have the behaviourconfiguration set to your behaviour.

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

Otherwise the graph-settings wont be used

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文