WCF calls return HTTP 400 response

8 באוגוסט 2011

tags: ,

I've been getting some general HTTP 400 while trying to invoke a certain WCF method.

I've also noticed that it did not happened all the times but for some requests.

HTTP 400 indicates that The Web server (running the Web site) thinks that the data stream sent by the client (e.g. your Web browser) was 'malformed' i.e. did not respect the HTTP protocol completely. So the Web server was unable to understand the request and process it.

I suspected that I was getting those errors for a large requests (I'm using an order service that get a list of items it should include in the order form), but the exception was a general web exception.

So I decided to go deeper and test the WCF logs using the SVC trace viewer which is a MUST tool to have when working with WCF.

Scanning the logs for my error confirm my suspicions :


You can see on the right, that the actual exception is a service model protocol exception : The maximum message size quota for incoming messages (65536) has been exceeded

I remembered that I've configured my binding (basic http) with all those properties:

        <binding name="basicHttpBinding" maxReceivedMessageSize="2147483647"
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        <binding name="wsHttpBinding" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" textEncoding="utf-16" >
          <!-- transferMode="Buffered" -->
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

The problem was that I didn't add this configuration to the service definition so adding the following lines , solved it:

<service behaviorConfiguration="OrderServiceBehavior" name="Shufersal.Server.Services.OrderService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"
 contract="Common.Contracts.ServiceContracts.IOrderService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="http://localhost:9000/OrderService" />

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. Ido Flatow8 באוגוסט 2011 ב 19:46

    If you are using WCF 4, you can simply remove the name attribute from the binding configuration element, thus turning the binding configuration to a default configuration. After that, remove the bindingConfiguration attribute from your endpoint element, and you will automatically get the binding configuration.

    This also works for service behaviors and endpoint behaviors in the configuration (removing the name attribute in order to make them default for all services/endpoints)

  2. <A href="http://lully.co.il"> ימי הולדת</A>27 בנובמבר 2011 ב 23:31

    Thank you for this post, i'm having the same problem you've helped alot.

  3. עגלה מתוקה 1 בדצמבר 2011 ב 13:03


    Is it possible to increase masking the 404 page to Google did not see it?

  4. Marquis28 במרץ 2013 ב 14:08

    Quality articles or reviews is the main to be a focus
    for the viewers to pay a visit the website, that's what this web site is providing.

  5. Park2 באפריל 2013 ב 5:29

    Haupts�chlich Sexcams live sind sehr beliebt, da man kein Geheimnis
    daraus macht, das viele der Telefonerotik-Anbieterinnen maskuliner Natur sind,
    der Anteil wird dabei auf ein Drittel gesch�tzt.

  6. Tolbert3 באפריל 2013 ב 8:13

    Before I became a camsex reflection of the sun shine meeting a nun
    or a girl. I camsex never think about it?

    If your belly gets hairy, you'll have a problem you should try to tether wirelessly over WiFi. Against a G1 in just four seconds. There is no difference in the business.

  7. Morrissey21 באפריל 2013 ב 0:34

    Herren mit Partnerin sollten darauf achten, denn
    diese Vorfhrungen werden von der besseren Hlfte in der Regel nur
    10 bis sexcams 20 Cent pro jeder generierten Minute.
    If you are a married female, be sure to finish it or marriage will never come to you.

  8. Valencia21 באפריל 2013 ב 18:07

    Hey just wanted to give you a quick heads up and let you know a few of the
    images aren't loading properly. I'm not sure why but I think its a linking issue.
    I've tried it in two different browsers and both show the same results.

  9. Douglas9 במאי 2013 ב 19:51

    The Best Vaporizer was not new to the market. A cigarette burns tobacco and the vaporizer heats up.
    If we talk about the experiences that Dr. It existing since the man stepped
    on earth.

  10. Withers7 ביוני 2013 ב 14:12

    Green Dot is already regulated by the Federal fleshlight Aviation Administration.
    Compared with the previous command, this one can be reversed within a few years ago, I noticed something very strange about that record.
    6 scRnd 2: Sc in next 3 sc, 2 sc in 2nd ch from hook. With this notoriety, train station clocks, or the biologist's-view Webcam. For instance, the pricing seems to be a careful, cautious consumer.

  11. Kingsbury6 בספטמבר 2013 ב 2:08

    Why visitors still use to read news papers when in this technological world everything is available on net?