代码之家  ›  专栏  ›  技术社区  ›  Kap

WCF:同时使用流媒体和用户名/密码身份验证

  •  1
  • Kap  · 技术社区  · 16 年前

    a) 客户端从服务器请求一个作为流传输的文件。文件可能是100MB或更大。我需要流或卡盘或任何东西,以确保IIS没有加载到内存中的整个包开始发送之前。 b) 客户端将传输一个标识以标识要下载的文件。应通过提供用户名/密码对用户进行身份验证。

    在我的其他服务中,我返回较小的文件,我使用以下绑定:

    <ws2007HttpBinding>
        <binding name="ws2007HttpExtern" maxReceivedMessageSize="65536000">
          <security mode="Message">
            <message clientCredentialType="UserName" />
          </security>
        </binding>        
      </ws2007HttpBinding>
    

    但是,正如我所说的,这对流式传输没有好处(消息加密需要对完整的消息进行加密,而流式传输时并非如此)。

    因此,我请求Microsoft支持,大致得到了以下建议:

    <bindings>
      <basicHttpBinding>
        <binding name="basicStreaming" 
          messageEncoding="Mtom" transferMode="StreamedResponse">
          <security mode="Transport">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
    </bindings>
    
    <services>
      <service behaviorConfiguration="MyProject.WCFInterface.DownloadBehavior"
        name="MyProject.WCFInterface.DownloadFile">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicStreaming"
          contract="MyProject.WCFInterface.IDownloadFile" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>    
    </services>
    
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyProject.WCFInterface.DownloadBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    

    Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].
    

    我有两个问题。 a) 您将如何配置WCF以实现此目标? b) 如果微软的建议是好的:我做错了什么,错误信息并不能真正帮助我。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Community Mohan Dere    6 年前

    1. 您是否在IIS 7上托管了其他WCF服务? Here

    2. Here 就是这样。

    据我所知,微软提出的解决方案是有效的。我用了同样的方法,效果很好。

    推荐文章