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

Posted by glenn.danthi on Stack Overflow See other posts from Stack Overflow or by glenn.danthi
Published on 2010-03-19T07:19:43Z Indexed on 2010/03/19 7:21 UTC
Read the original article Hit count: 1159

Filed under:
|
|
|

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...

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf