具有 Http 基本身份验证的 WCF

发布于 2024-08-18 05:02:24 字数 568 浏览 3 评论 0原文

我正在构建一个需要可供各种潜在平台访问的 Web 服务,包括许多较旧的 ASP 和 ASP .NET 应用程序。经过一番研究,我选择了同时具有 REST (webHttpBinding) 和 SOAP (wsHttpBinding) 端点的 WCF 服务(这样,我可以支持广泛的平台,并且仍然能让 .NET 编码人员满意)。

为了安全起见,我对我自己的用户名/密码数据库使用 SSL 和 HTTP 基本身份验证。因此,我编写了一个 HttpModule 来处理用户名和密码并检查 SSL。现在,REST 设置工作正常,但 SOAP 端点出现问题。无论我使用什么设置,SOAP 客户端都不会向我发送可用于身份验证的 WWW-Authorization 标头。我假设设置类似 的内容应该告诉 WCF 我需要一个授权标头,并且该信息将由 Visual studio(或任何客户端)获取)当它创建网络引用时。也许我只是太天真了。

总结一下这个问题:有什么方法可以告诉 WCF 向我发送 WWW-Authorization 标头(即 HTTP 基本标头)以及肥皂消息吗?

I'm building a webservice that needs to be accessible to a variety of potential platforms, including a number of older ASP and ASP .NET applications. After some research, I settled on a WCF service with both a REST (webHttpBinding) and SOAP (wsHttpBinding) endpoint (that way, I can support a wide range of platforms and still make the .NET coders happy).

For security, I'm using SSL and HTTP Authentication Basic against my own database of username/passwords. So I've written an HttpModule to handle the usernames and passwords and check for SSL. Now, the REST setup is working perfectly, but I'm having problems with the SOAP endpoint. No matter what settings I use, the SOAP client never sends me a WWW-Authorization header that I can use to authenticate. I'm assuming that setting something like <message clientCredentialType="UserName" /> should tell WCF that I expect an Authorization header, and that information will be picked up by Visual studio (or whatever client) when it creates a web reference. Perhaps I'm just being hopelessly naive.

So to summarize the question: is there any way that I can tell WCF to send me a WWW-Authorization header (ie, an HTTP basic header) along with the soap messages?

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

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

发布评论

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

评论(1

赴月观长安 2024-08-25 05:02:24

您可以为身份验证创建自定义标头。

看看 这里

You can create custom headers for your authentication.

Have a look here

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