【发布时间】:2023-03-31 04:49:01
【问题描述】:
我有一个具有以下要求的 WCF 服务: a) 客户端向服务器请求一个文件,该文件作为流传输。文件可能为 100MB 或更大。我需要流式传输或卡盘或其他任何方式来确保 IIS 在开始发送之前不会将整个包加载到内存中。 b) 客户端将传输一个 ID 来识别要下载的文件。用户应通过提供用户名/密码进行身份验证。 c) 虽然通信的用户名/密码部分需要加密,但下载文件的加密对于我们的用例来说是可选的。
我正在返回较小文件的其他服务,我使用以下绑定:
<ws2007HttpBinding>
<binding name="ws2007HttpExtern" maxReceivedMessageSize="65536000">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</ws2007HttpBinding>
但是,正如我所说,这对流式传输没有好处(消息加密需要对完整的消息进行加密,而流式传输则不是这样)。
所以,我询问了微软的支持,我或多或少得到了以下建议:
<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 建议是好的:我做错了什么,错误消息并没有真正帮助我。
谢谢。
【问题讨论】:
标签: .net wcf streaming wcf-security