【发布时间】:2010-09-19 17:08:16
【问题描述】:
我正在使用蒸汽模式下的基本 WCF Web 服务从服务器下载文件。
我已将服务器端的绑定指定为
<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>
我的客户端绑定 xml 看起来像
<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>
我正在尝试使用
下载文件 byte[] buffer = new byte[32768];
while (true)
{
int read = serverStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
fs.Write(buffer, 0, read);
}
即使我指定了 maxBytesPerRead="8192",我在调用中可以读取的最大字节数也只有 4096。
【问题讨论】:
-
您确定这些绑定配置确实被您的服务和客户端端点使用了吗??
-
是的,我很确定。没有定义其他配置。
-
是web.config中的maxRequestLength吗?
-
您的客户端创建代码是什么样的?如果您没有调用默认构造函数,则可能没有使用 app.config 中指定的配置。
标签: c# wcf wcf-binding