我目前正致力于将文件上传和下载到WCF服务的解决方案。客户端是继承自ClientBase的类。我已经阅读了有关StackOverflow和其他地方的流媒体和链接的MSDN article,但我似乎无法弄清楚为什么我仍然收到有关消息大小太小的消息。到目前为止,我已经使用小文件测试了解决方案并且它可以工作
该服务托管在IIS 7.5
中这是来自客户端应用程序的App.config
<system.web>
<httpRuntime maxRequestLength="67108864" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingHttpBinding"
maxBufferSize="65536"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/UpdateService.svc"
binding="basicHttpBinding"
contract="IUpdateService"
name="updateServiceEndpoint"/>
</client>
</system.serviceModel>
以下是服务器中的相关部分
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="UpdateService" behaviorConfiguration="UpdateServiceBehavior">
<endpoint binding="basicHttpBinding" bindingName="LargeFileStreamingWebHttpBinding" contract="IUpdateService"></endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="UpdateServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingWebHttpBinding"
maxBufferSize="65536"
maxReceivedMessageSize="2147483647"
/>
</basicHttpBinding>
</bindings>
</system.serviceModel>
此外,我在服务器和客户端配置中添加了以下内容:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
这就是我实例化客户端的方式
public class UpdateClient : ClientBase<IUpdateService>, IUpdateService
{
public UpdateClient() : base("updateServiceEndpoint") {}
}
那么我有什么想法可能会出错吗?任何帮助表示赞赏。
-Thanks!
答案 0 :(得分:0)
找到答案 - 一个非常简单的错误,客户端/端点条目缺少bindingConfiguration属性