繁体   English   中英

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

[英]WCF: Using Streaming and Username/Password authentication at the same time

我有一个具有以下要求的WCF服务:a)客户端从服务器请求文件,该文件作为流传输。 文件可能大于或等于100MB。 我需要流式处理或卡住处理或其他任何操作以确保IIS在开始发送之前不会将整个程序包加载到内存中。 b)客户端将传输一个ID,以标识要下载的文件。 用户应通过提供用户名/密码进行身份验证。 c)虽然通信的用户名/密码部分需要加密,但对于我们的用例,下载文件的加密是可选的。

我的其他服务(我要返回较小的文件)使用以下绑定:

<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].

到目前为止,我正在使用Web开发服务器(用于生产IIS7)。

我有两个问题。 a)您将如何配置WCF以实现目标? b)如果MS提案是好的:我做错了,错误消息并没有真正帮助我。

谢谢。

此错误通常与在IIS 7上托管WCF服务有关。默认情况下不支持WCF,因此,这里是一些可以执行的故障排除。

  1. 您是否已在IIS 7上托管了其他WCF服务? 您可能需要研究在IIS 7服务器上添加WAS服务功能。 是一个很好的教程。

  2. Https要求您使用正确的SSL证书设置IIS,并将HTTPS绑定添加到您的站点。 是怎么回事。

据我所知,MS建议的解决方案有效。 我使用了相同的方法,并且效果很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM