Reputation: 33
I have a windows application which calls to a WCF service to build a specific URL.
The WCF function which gets called from windows application accepts location details in the form of an array.
I face a problem the when array size sent to WCF function is small (for eg. 10) then the service returns correct result.
But when the array size grows (for eg. >200) then service returns a 400 Bad request.
I am not sure if the array size or the array contents are causing this problem.
I have tried to change the server (service) side web.config to accept the max buffer size.
<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>
Still I am facing the same issue.
In client side (here windows application) how can we set the configuration settings so that client will be able to send large data to server side?
Upvotes: 3
Views: 247
Reputation: 768
You need to increase the Reader Quota in the server config file as well as client config file.
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
And maxReceivedMessageSize and bufferSize:
<httpTransport transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"/>
You might also need to add dataContractSerializer into your Service Behaviour.
<serviceBehaviors>
<behavior name="Your SB">
<serviceMetadata httpGetEnabled="True"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug
includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
Upvotes: 2
Reputation: 4892
You need to make the changes on the Client side. Change both maxBufferSize
and maxReceivedMessageSize
. I faced a similar problem just yesterday and fixed it by resetting those values to a higher value.
Note: In fact i didn't make any changes on the service(server).
Upvotes: 0