Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uploading large xml to WCF REST service -> 400 Bad request

Tags:

rest

c#

wcf

upload

I am trying to upload large xml files to a REST service... I have tried almost all methods specified on stackoverflow on google but I still cant find out where I am going wrong....I cannot upload a file greater than 64 kb!..

I have specified the maxRequestLength :

<httpRuntime maxRequestLength="65536"/>

and my binding config is as follows :

<bindings>
  <webHttpBinding>
    <binding name="RESTBinding" maxBufferSize="67108864" maxReceivedMessageSize="67108864" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>   
  </webHttpBinding>
</bindings>

In my C# client side I am doing the following :

WebRequest request = HttpWebRequest.Create(@"http://localhost.:2381/RepositoryServices.svc/deviceprofile/AddDdxml");

        request.Credentials = new NetworkCredential("blah", "blah");
        request.Method = "POST";
        request.ContentType = "application/xml";
        request.ContentLength = byteArray.LongLength;


        using (Stream postStream = request.GetRequestStream())
        {
            postStream.Write(byteArray, 0, byteArray.Length);
        }

There is no special configuration done on the client side...

I have tried fiddler...The client is sending a proper request...But the server immediately responds with a 400..

like image 309
Glenn Danthi Avatar asked Mar 19 '10 07:03

Glenn Danthi


1 Answers

Got my answer!....http://forums.asp.net/p/1375070/2887691.aspx.....phew!....spent 2 days behind this!

like image 103
Glenn Danthi Avatar answered Sep 29 '22 05:09

Glenn Danthi