locked
Large Upload causes HTTP400 Bad Request with no error message RRS feed

  • Question

  • I'm getting a problem with uploading data (unrelated to my deleting issue). For the most part insert/update requests are going through without a problem. I'm trying to get a large amount of reference data set up in my database ready for a release of my iPhone software (which I'm pre-loading the initial data from my Sync4.0 database). I wrote my Silverlight client to make it easier for me to enter this data with the key being that there is going to be a lot of duplication which I'd like the SL app to handle for me. Every aspect of the data is updating successfully when I do it in chunks. The duplication involves basically making a new container and then creating a new entity set inside that which copies the details of the source container's entities. This works for small containers but all of a sudden when I try and copy a large container the server responds to the request with HTTP400 Bad Request. The request interceptors are not firing and the body of the response is empty. The large source container that I'm trying to copy was built up in chunks (about 20% at a time) using the service so there's nothing data-wise which I would expect to cause the service to respond with a Bad Request. The content-length of an example of a failing request is in the order of 100000. The largest request that has succeeded is around 15000. This is a pretty major issue for me because the reference data updates are tiny compared with what I'll be expecting the service to handle when I get the full production system up and running.
    Friday, January 7, 2011 3:41 AM

Answers

  • Hi Peter,

    M.Bi is correct, this should be a simple WCF configuration change to allow a larger message size. I believe the default message size is 64KB. I increase the message size the following way:

    Add a binding element under <system.ServiceModel> and reference this configuration for your service under <system.ServiceModel><services><service><endpoint>

    <services>
     <!-- The name of the service -->
     <service name="WcfSyncServiceTest.Service1">
      <!-- you can leave the address blank or specify your end point URI -->
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="higherMessageSize" contract="Microsoft.Synchronization.Services.IRequestHandler">
      </endpoint>
     </service>
    </services>
    <bindings>
     <webHttpBinding>
      <!-- configure the maxReceivedMessageSize  value to suit the max size of
     the request ( in bytes ) you want the service to recieve-->
      <binding name="higherMessageSize" maxReceivedMessageSize="900000"/>
     </webHttpBinding>
    </bindings>

    • Marked as answer by Peter Mauger Saturday, January 8, 2011 1:43 AM
    Friday, January 7, 2011 6:22 PM

All replies

  • This might be caused by the server's configured limit for POST data which defaults to 200kB for IIS 7 i think. At least you could try to explicitly configure bigger sizes and see if that solves your problem.

    Add this to your web.config to allow up to 1MB of POST data:

     <system.webServer>
      <asp>
       <limits maxRequestEntityAllowed="1048576" />
      </asp>
     </system.webServer>
    
    
    For more details check related docs (this is quite different across IIS versions).

     

    Friday, January 7, 2011 11:04 AM
  • Hi Peter,

    M.Bi is correct, this should be a simple WCF configuration change to allow a larger message size. I believe the default message size is 64KB. I increase the message size the following way:

    Add a binding element under <system.ServiceModel> and reference this configuration for your service under <system.ServiceModel><services><service><endpoint>

    <services>
     <!-- The name of the service -->
     <service name="WcfSyncServiceTest.Service1">
      <!-- you can leave the address blank or specify your end point URI -->
      <endpoint address="" binding="webHttpBinding" bindingConfiguration="higherMessageSize" contract="Microsoft.Synchronization.Services.IRequestHandler">
      </endpoint>
     </service>
    </services>
    <bindings>
     <webHttpBinding>
      <!-- configure the maxReceivedMessageSize  value to suit the max size of
     the request ( in bytes ) you want the service to recieve-->
      <binding name="higherMessageSize" maxReceivedMessageSize="900000"/>
     </webHttpBinding>
    </bindings>

    • Marked as answer by Peter Mauger Saturday, January 8, 2011 1:43 AM
    Friday, January 7, 2011 6:22 PM
  • Awesome. Just in case anyone else bumps into this the service name should be namespace.serviceclass (I was struggling with this for a few minutes... I think I'm going to need to brush up on WCF a bit more before I think about deploying this one...)

    Saturday, January 8, 2011 1:43 AM