Large WCF web service request failing with (400) HTTP Bad Request?

Try setting maxReceivedMessageSize on the server too, e.g. To 4MB.

Try setting maxReceivedMessageSize on the server too, e.g. To 4MB: The main reason the default (65535 I believe) is so low is to reduce the risk of Denial of Service (DoS) attacks. You need to set it bigger than the maximum request size on the server, and the maximum response size on the client. If you're in an Intranet environment, the risk of DoS attacks is probably low, so it's probably safe to use a value much higher than you expect to need.

By the way a couple of tips for troubleshooting problems connecting to WCF services: Enable tracing on the server as described in this MSDN article. Use an HTTP debugging tool such as Fiddler on the client to inspect the HTTP traffic.

Amazing - that's all it was. Thankyou heaps for your reply! – Damovisa Apr 24 '09 at 6:06 Thanks for the link to enable Tracing!

– Colin Desmond Aug 27 '09 at 20:04 I tried to do the same at my end, but could not taste success. – Kangkan Sep 9 '10 at 8:34.

It might be useful to debug the client, turn off Tools\Options\Debugging\General\'Enable Just My Code', click Debug\Exceptions\'catch all first-chance exceptions' for managed CLR exceptions, and see if there is an exception under-the-hood on the client before the protocol exception and before the message hits the wire. (My guess would be some kind of serialization failure. ).

I'll give that a go, thanks :) – Damovisa Apr 24 '09 at 5:41.

I was also getting this issue also however none of the above worked for me as I was using a custom binding (for BinaryXML) after an long time digging I found the answer here :- Sending large XML from Silverlight to SVC (WCF) As am using a customBinding, the maxReceivedMessageSize has to be set on the httpTransport element under the binding element in the web.config.

For what it is worth, an additional consideration when using . NET 4.0 is that if a valid endpoint is not found in your configuration, a default endpoint will be automatically created and used. The default endpoint will use all default values so if you think you have a valid service configuration with a large value for maxReceivedMessageSize etc., but there is something wrong with the configuration, you would still get the 400 Bad Request since a default endpoint would be created and used.

This is done silently so it is hard to detect. You will see messages to this effect (e.g.'No Endpoint found for Service, creating Default Endpoint' or similar) if you turn on tracing on the server but there is no other indication (to my knowledge).

User469104: Very good tip. Thanks. Is there a way to force the server to use a hand-declared endpoint without overwriting the default ServiceHost?

– RaSor May 12 at 17:16.

Just want to point out Apart from MaxRecivedMessageSize, there are also attributes under ReaderQuotas, you might hit number of items limit instead of size limit. MSDN link is here.

In the server in . NET 4.0 in web. Config you also need to change in the default binding.

Set the follwowing 3 parms.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions