开发者

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

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开发者_如何学JAVA 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..


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


For WCF SOAP all I had to do was:

 <binding name="uploadFilesBasicHttpBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:10" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00">
    <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
    <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName"/>
    </security>
  </binding>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜