My call to my WCF web service is failing with System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.
Checking Fiddler, I see that I'm sending:
Content-Length: 149839
Which is over 65KB.
Enabling WCF tracing on the server, I see:
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.
Adding this property doesn't solve the issue.
I've tried with just that property, and (later) with various others that posts have suggested. Here's what I have currently (on the server):
<basicHttpBinding> <binding name="PricerServiceSoap" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding>
My sole endpoint (under <client>
) is:
<endpoint address="/NetPricingService/Service.asmx" binding="basicHttpBinding" bindingConfiguration="PricerServiceSoap" contract="Pricing.PricerService.PricerServiceSoap" name="PricerServiceSoap" />
I've also added:
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
under <behavior>
.
I've even run (for IIS 7):
%windir%\system32\inetsrv\appcmd set config "WebServicesDev/PricingService" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost
Nothing makes any difference.
One catch is that this is a WCF service meant to replace an older ASMX service. The service skeleton was generated with svcutil from existing WSDL. I can't change the client configurations (and the clients are in multiple languages). My test client project imported the service with Add Web Reference (under Add Service Reference / Advanced
), so I have no WCF configuration. However, the test client works if I point it at the older ASMX service.
How can I fix or diagnose this?
Additional info
If I use the Microsoft Service Configuration Editor to generate the config (setting maxReceivedMessageSize and maxBufferSize), it works. The problem is that the endpoint is then specified under <service>
, and it won't let me specify the /NetPricingService/Service.asmx relative address. If I edit the bindings in the svcutil-generated config (where the endpoint is under <client>
), it doesn't work with large requests.
The 413 status code indicates that the request was larger than the server can handle, either due to physical constraints or settings.
The answer was staring me in the face.
The config generated by svcutil was for the client. I was using it on the server.
I was editing the bindings for the endpoints specified under <client>
, which made absolutely no difference to the service.
Adding a proper <service>
endpoint and setting the maxReceivedMessageSize and maxBufferSize on its binding resolved the issue.
I had a similar problem. For me, the problem was that my endpoint did not explicitly name the binding using bindingConfiguration
and so must have been using some default one somewhere.
I had:
<webHttpBinding> <binding name="myXmlHttpBinding" maxReceivedMessageSize="10485760" maxBufferSize="10485760"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> <security mode="None"/> </binding> </webHttpBinding>
and my endpoint defined as:
<service name="blah.SomeService"> <endpoint address="" behaviorConfiguration="WebHttpBehavior" binding="webHttpBinding" contract="blah.ISomeService"> <identity> <dns value="localhost"/> </identity> </endpoint> </service>
It worked once I changed the endpoint to:
<service name="blah.SomeService"> <endpoint address="" behaviorConfiguration="WebHttpBehavior" binding="webHttpBinding" bindingConfiguration="myXmlHttpBinding" contract="blah.ISomeService"> <identity> <dns value="localhost"/> </identity> </endpoint> </service>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With