views:

90

answers:

2

I am using basic WCF web service in steaming mode to download files from server.

I have specified binding on server side as

     <basicHttpBinding>
        <binding name="DBUpdateServiceBinding" closeTimeout="23:59:59"
           openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59"
           maxReceivedMessageSize="10067108864" messageEncoding="Mtom"
           transferMode="Streamed">
           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="8192" maxNameTableCharCount="16384" />
        </binding>
     </basicHttpBinding>

and my client side binding xml looks like

  <bindings>
     <basicHttpBinding>
        <binding name="ws" closeTimeout="23:59:59" openTimeout="23:59:59"
           receiveTimeout="23:59:59" sendTimeout="23:59:59" maxReceivedMessageSize="10067108864"
           messageEncoding="Mtom" transferMode="Streamed">
           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="8192" maxNameTableCharCount="16384" />
           <security>
              <transport realm="" />
           </security>
        </binding>
     </basicHttpBinding>
  </bindings>

I am trying to download files using

   byte[] buffer = new byte[32768];
   while (true)
   {
      int read = serverStream.Read(buffer, 0, buffer.Length);
      if (read <= 0)
         break;
      fs.Write(buffer, 0, read);
   }

Even though I have specified maxBytesPerRead="8192", max bytes that I can read in a call is only 4096.

A: 

is it the maxRequestLength in web.config?

yamspog
@yamspog there are comments for questions.
Sergey Mirvoda
+1  A: 

Unless you have very specific security requirements, you might want to consider setting the maximum sizes to Int32.MaxValue. It will save you some debugging time. Then tune it down to a more reasonable value if needed.

Johann Blais