【问题标题】:Client side configuration settings客户端配置设置
【发布时间】:2013-01-22 14:49:48
【问题描述】:

我有一个调用 WCF 服务来构建特定 URL 的 Windows 应用程序。

从 Windows 应用程序调用的 WCF 函数接受数组形式的位置详细信息。

我遇到一个问题,当发送到 WCF 函数的数组大小很小(例如 10)时,服务会返回正确的结果。

但当数组大小增加时(例如 >200),服务会返回 400 Bad request。

我不确定是数组大小还是数组内容导致了这个问题。

我已尝试更改服务器(服务)端 web.config 以接受最大缓冲区大小。

<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceContract" 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="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 

maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>


</basicHttpBinding>
</bindings>

<system.web>
    <compilation debug="true" targetFramework="4.0" />
            <httpRuntime executionTimeout="90" maxRequestLength="1048576" useFullyQualifiedRedirectUrl="false" 

minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
  </system.web>

我仍然面临同样的问题。

在客户端(这里是windows应用程序)我们如何设置配置设置,以便客户端能够将大数据发送到服务器端?

【问题讨论】:

    标签: windows wcf configuration client


    【解决方案1】:

    您需要在客户端进行更改。更改maxBufferSizemaxReceivedMessageSize。我昨天遇到了类似的问题,并通过将这些值重置为更高的值来修复它。

    注意:实际上我没有对服务(服务器)进行任何更改。

    【讨论】:

      【解决方案2】:

      您需要在服务器配置文件和客户端配置文件中增加 Reader Quota。

      <readerQuotas maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" />
      

      还有 maxReceivedMessageSize 和 bufferSize:

      <httpTransport transferMode="Buffered"
      maxReceivedMessageSize="2147483647"
      maxBufferSize="2147483647"/>
      

      您可能还需要将 dataContractSerializer 添加到您的服务行为中。

      <serviceBehaviors>
      <behavior name="Your SB">
      <serviceMetadata httpGetEnabled="True"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceDebug 
      includeExceptionDetailInFaults="False" />
      </behavior>
      </serviceBehaviors>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-12-21
        • 2011-05-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多