2013-02-07 202 views
3

我有一个Windows应用程序,它调用WCF服务来构建特定的URL。客户端配置设置

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

我面临一个问题,当数组大小发送到WCF函数是小(例如10),然后服务返回正确的结果。

但是,当数组大小增加(例如> 200)时,服务返回400错误请求。我不确定数组大小或数组内容是否导致此问题。

我试图改变服务器(服务)端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应用程序),我们如何设置配置设置,以便客户端能够发送大量数据到服务器端?

回答

2

您需要在服务器配置文件以及客户端配置文件中增加读者配额。

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

而且maxReceivedMessageSize和缓冲区大小:

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

您可能还需要添加DataContractSerializer的进入你的服务行为。

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

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

注:事实上,我没有对服务(服务器)做任何更改。