3) True、wsHttpBinding 和 wsDualHttpBinding 是唯一支持会话的 HTTP 绑定
5) False,为了对服务调用者进行身份验证,您不一定需要任何传输级别的安全性(例如 SSL/HTTPS)。唯一的要求是将 IIS 配置为为虚拟目录启用 集成 Windows 身份验证。然后在 WCF 中,您可以通过三种方式启用此方案:
a) 在带有 Windows 凭据 (HTTPS) 的 wsHttpBinding 上使用传输级安全性
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SecurityEnabledWsHttp">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
b) 在带有 Windows 凭据 (HTTP) 的 wsHttpBinding 上使用消息级安全性
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SecurityEnabledWsHttp">
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
c) 在 ASP.NET 兼容模式 下运行您的服务并在 ASP.NET (HTTP) 中启用 Windows 身份验证
<system.web>
<authentication mode="Windows" />
</system.web>
请注意,在 a 和 b 中,您将通过以下方式从服务中访问调用者的身份:
OperationContext.Current.ServiceSecurityContext.WindowsIdentity
6) True,必须在 wsHttpBinding 上启用传输级安全性才能使用 HTTPS
7) False,Reliable Sessions 是用于 WCF 会话的 Reliable Messaging 的特定实现。 Reliable Messaging 是一种 WS-* 标准规范,旨在保证在不可靠的网络上传递消息。您可以在没有可靠消息传递的情况下使用 WCF 会话,反之亦然。使用此属性在服务合同上启用会话:
[ServiceContract(SessionMode=SessionMode.Required)]
public interface IMyService {
// ...
}
还请记住,为了维护服务调用之间的状态,您必须明确地在服务合同实现上启用适当的实例模式:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class MyService : IMyService {
// ...
}
WCF 中有两种会话:安全会话和可靠会话。 wsHttpBinding 和 netTcpBinding 的默认设置是使用安全会话。
对于 wsHttpBinding,这是通过使用 消息级安全 来完成的客户端的凭据,这是绑定的默认设置。
对于 netTcpBinding,会话是通过使用 TCP 协议的设施在传输级别建立的.
这意味着只需切换到 wsHttpBinding 或 netTcpBinding 即可启用对 WCF 会话的支持。
另一种方法是使用可靠会话。这必须在绑定配置中显式启用,并消除对 wsHttpBinding 使用消息安全性的要求。所以这会起作用:
<bindings>
<wshttpbinding>
<binding name="ReliableSessionEnabled">
<reliablesession enabled="True" ordered="False" />
<security mode="None" />
</binding>
</wshttpbinding>
</bindings>
8) False,可靠会话的使用独立于通信通道的安全设置。
更详细的解释请看this article。