WSHttpBinding 和 Https 问题

发布于 2024-11-29 12:59:16 字数 676 浏览 1 评论 0原文

我想同时使用会话和 SSL,因此我设置了所有证书并确保 WCF 服务上的所有内容都设置正确。我已经尝试了一切,但似乎无法让它发挥作用。它向我抛出一个 InvalidoperationException 异常,指出 WsHttpBinding 无法创建安全会话,并且我应该使用 MessageSecurity 而不是 TransportSecurity。但是我想使用 Https 而不是 Http,所以我想使用 TransportSecurity。有人可以帮我吗。提前致谢。

WsHttpBinding 的 App.config:

   <wsHttpBinding>
    <binding name="WSHttpBinding">
     <reliableSession enabled="True" />
     <security mode="Transport">
      <transport clientCredentialType="None"/>
     </security>
    </binding>
   </wsHttpBinding>

编辑:我忘记提及当我尝试调用 ServiceHost.Open() 时会发生 InvalidOperationException,因此日志记录不会有太大作用,但感谢您提及它。

I want to use Sessions and SSL at the same time so I set up all the certificates and made sure everything was set up properly on the WCF service. I've tried about everything but I cant seem to get this to work. It throws me a InvalidoperationException saying that the WsHttpBinding can't create secure sessions and that I should use MessageSecurity instead of TransportSecurity.But I want to use Https and not Http so I want to use TransportSecurity. Could Anyone please help me out. Thanks in advance.

App.config for WsHttpBinding:

   <wsHttpBinding>
    <binding name="WSHttpBinding">
     <reliableSession enabled="True" />
     <security mode="Transport">
      <transport clientCredentialType="None"/>
     </security>
    </binding>
   </wsHttpBinding>

Edit: I forgot to mention that the InvalidOperationException Occurs when I try to call ServiceHost.Open() So the Logging will not do much good, but thank you for mentioning it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夕嗳→ 2024-12-06 12:59:16

我没有尝试过,但 MSDN 说

要通过 HTTPS 使用可靠会话,您必须创建使用可靠会话和 HTTPS 传输的自定义绑定。

尝试文章中描述的自定义绑定。

编辑:

我检查了 Reflector 为什么它不能与 WsHttpBinding 一起使用。 WsHttpBinding 在初始化安全性时包含此代码:

if (isReliableSession && !this.IsSecureConversationEnabled())
{
    throw ...
}

这可能意味着 WsHttpBinding 允许通过不安全的通道或通过消息安全和安全对话保护的通道使用可靠的会话。

I didn't try it but MSDN says:

To use a reliable session over HTTPS, you must create a custom binding that uses a reliable session and the HTTPS transport.

Try the custom binding described in the article.

Edit:

I checked with Reflector why it doesn't work with WsHttpBinding. WsHttpBinding contains this code when initializing security:

if (isReliableSession && !this.IsSecureConversationEnabled())
{
    throw ...
}

It probably means that WsHttpBinding allows using reliable session over unsecured channel or over channel secured with message security and secure conversation.

少年亿悲伤 2024-12-06 12:59:16

我建议您启用 WCF 日志记录 并查看生成的日志文件使用 SvcTraceViewer。这应该为您提供有关正在发生的事情的更多详细信息,并且通常可以帮助我追踪更困难的 WCF 问题。

I would suggest you enable WCF logging and take a look at the resulting logfile using SvcTraceViewer. This should provide you with a lot more detail about what's going on and usually helps me in tracking down the more difficult WCF issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文