2011-09-07 52 views
-1

我目前正在研究上传和下载文件到WCF服务的解决方案。客户端是从ClientBase继承的类。我读过关于StackOverflow和其他地方的流媒体和链接的MSDN article,但我似乎无法弄清楚为什么我仍然收到有关邮件大小太小的消息。我已经用小文件测试了解决方案,并且它工作正常。从ClientBase上传文件到WCF服务<T>

该服务托管在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") {} 
} 

所以不会有任何想法,我可以去错了吗?任何帮助表示赞赏。

- 谢谢!

+0

是服务类的名称只是“UpdateService”,或者它的一些命名空间属于?如果是后者,则需要在<'上具有完全限定的名称,以便获取配置。 – carlosfigueira

+0

为了简洁起见,我省略了服务合约名称空间 – abjbhat

+0

由于本地化过于封闭,因为没有其他人会犯这个特别的错误,因此无法通过搜索这个问题找到答案。 –

回答

0

找到了答案 - 一个很简单的错误,客户端/端点进入失踪的bindingConfiguration属性