Reputation: 1656
I need some insight on where to look further related to a WCF error I am getting about the Request Entity Too Large (Error 413).
Pretty much, the service is a simple [OperationContract] accepting a string as a parameter.
<IService.cs>
[OperationContract]
string UploadReportText(string ReportText);
<Service.cs>
public string UploadReportText(string ReportText)
{
// Code to process data passed.
}
I've already set the web configuration for the service as follows:
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
Although I believe the uploadReadAhead value in IIS needs not be touched (as I am not using SSL), I still modified it to have a value of 2147483647.
Tracing one of the applications that call the service in Chrome, I can see that the data 'Content-Length' is 169786.
I am really stumped where to look further related to this.
If I set the string data being passed to the service to a smaller length, I am not getting an error. Most of the search I did related to this all points to the maxReceivedMessageSize needs to be adjusted to the maximum possible value, but setting it in the web configuration seems to not have any effect.
I enabled logging, and I got this message:
Exception details: System.ServiceModel.ProtocolException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
Upvotes: 2
Views: 13064
Reputation: 11
In my case I had the following configuration.
Four final points:
<endpoint address="rest" binding="webHttpBinding"
contract="MSService.IService"
behaviorConfiguration="web"
bindingConfiguration="webhttpsBinding"/>
<endpoint address="" binding="basicHttpBinding" name="Service"
contract="MSService.IService" />
<endpoint address="" binding="basicHttpsBinding" name="Service"
contract="MSService.IService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
A definite link:
A protocolMapping section:
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
I set up the only bindig, with:
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647 maxBufferPoolSize="2147483647
And finally I added the readeQuotas section:
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/>
My configuration is:
<bindings><webHttpBinding>
<binding name="webhttpsBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
Upvotes: 0
Reputation: 5804
You also need to do the same thing on your client-side as well.
Does your client-side configuration (app.config
also include that large message size binding configuration?
Upvotes: 0
Reputation: 29151
For me, I just needed to add this chunk to my web.config:
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647777" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
My web.config was already using the webHttpBinding
binding (as shown below), it just needed this <bindings>
section to allow it to upload large files.
<services>
<service name="PocketCRMServices.Service1">
<endpoint address="../Service1.svc"
binding="webHttpBinding"
contract="PocketCRMServices.IService1"
behaviorConfiguration="webBehaviour" />
</service>
</services>
Upvotes: 0
Reputation: 28520
As Vignesh said, you don't have a name assigned to your defined binding. This makes it the default configuration for that binding (in WCF 4.0+ later), so you actually have two choices. You can give it a name, create an explicit endpoint and reference it via the bindingCongifuration
, per Vignesh's suggestion.
Or, you can use the <proctolMapping>
part of the <system.serviceModel>
section to assign the webHttpBinding
as the default binding for http
(the normal WCF default binding for http is basicHttpBinding
:
<system.serviceModel>
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocoalMapping>
</system.serviceModel>
This goes in your service's config file.
Upvotes: 0
Reputation: 28403
First of all: on your server side, you define the binding configuration with larger message size, but you don't reference it from your endpoint.
<service behaviorConfiguration="WCFReferrals.Service1Behavior"
name="WCFReferrals.Referrals">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="LargeSizeMessages" <== you need to reference the binding config (by specifying its name
contract="WCFReferrals.IReferrals">
</endpoint>
.....
</service>
....
<binding name="LargeSizeMessages" <== give it a meaningful name
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
Upvotes: 7