Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maxReceivedMessageSize not fixing 413: Request Entity Too Large

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.

like image 401
TrueWill Avatar asked Jan 31 '13 22:01

TrueWill


People also ask

What does HTTP Error 413 mean?

The 413 status code indicates that the request was larger than the server can handle, either due to physical constraints or settings.


2 Answers

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.

like image 58
TrueWill Avatar answered Sep 24 '22 16:09

TrueWill


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> 
like image 39
matt burns Avatar answered Sep 23 '22 16:09

matt burns