我创建了一个接收大文件的服务。之后,我将其发布在本地 IIS7 上。之后,我创建了带有服务参考的测试客户端。当我尝试将大文件发送到服务器时,我得到:Bad request (400)。
该异常的服务跟踪: 已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。
服务器配置:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true" executionTimeout="14400"/>
<customErrors mode="Off" /></system.web>
捆绑
<wsHttpBinding>
<binding name="wsBufferedHttpsBinding" messageEncoding="Mtom"
maxReceivedMessageSize="11534336" maxBufferPoolSize="524288"
sendTimeout="00:05:00" receiveTimeout="00:05:00" openTimeout="00:05:00" closeTimeout="00:05:00" >
<readerQuotas maxDepth="64" maxStringContentLength="11534336" maxArrayLength="11534336"
maxBytesPerRead="11534336" maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
服务
<service name="MyService">
<endpoint address=""
binding="wsHttpBinding"
bindingName="wsBufferedHttpsBinding"
contract="IServiceContract">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<endpoint address="soap12IssuedToken" binding="customBinding"
bindingConfiguration="soap12IssuedToken" name="soap12IssuedToken"
bindingNamespace="http://url"
contract="IServiceContract" />
</service>
这项服务到底有什么问题?我在任何地方都设置了这个消息大小。