如何在SiteMinder后面调用WCF Http Service

发布于 2024-10-21 09:33:41 字数 200 浏览 9 评论 0原文

我正在尝试调用托管在 ASP.NET 应用程序中的 WCF 4 Http Web 服务。该服务受 SiteMinder 保护。

我想知道如何以编程方式调用 Web 服务,更具体地说,我需要传递哪些信息才能在 SiteMinder 中获得授权来访问我的资源。

我从同一服务器上运行的 ASP.NET 应用程序发出请求,因此我可以访问身份验证 cookie。

I am trying to call WCF 4 Http Web Services which are hosted within an ASP.NET application. The Service is protected behind SiteMinder.

I was wondering how I could programmatically call the web service, and more specifically what information will I need to pass to be authorized within SiteMinder to access my resources.

I am making the request from the ASP.NET application running on the same server, so I have access to the authentication cookie.

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

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

发布评论

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

评论(1

孤凫 2024-10-28 09:33:41

首先获取 SiteMinder 身份验证令牌,如下所示:

    private string ObtainSiteMinderSession()
    {
        var cookie = Request.Cookies["SMSESSION"];
        return cookie != null ? cookie.Value : string.Empty;
    }

然后像这样通过 Web 服务调用传递此令牌(使用 Microsoft.Http.dll):

using Microsoft.Http;
using Microsoft.Http.Headers;

...

var Client = new HttpClient(baseUri);

// Add SMSESSION
var smCookie = new Cookie();
smCookie.Add("SMSESSION", ObtainSiteMinderSession());
Client.DefaultHeaders.Cookie.Add(smCookie);

using (var httpRequest = new HttpRequestMessage(Verbs.GET, "/LoadData/"))
{ ... }

First obtain the SiteMinder authentication token like so:

    private string ObtainSiteMinderSession()
    {
        var cookie = Request.Cookies["SMSESSION"];
        return cookie != null ? cookie.Value : string.Empty;
    }

Then pass this token as with your web service calls like so (using Microsoft.Http.dll):

using Microsoft.Http;
using Microsoft.Http.Headers;

...

var Client = new HttpClient(baseUri);

// Add SMSESSION
var smCookie = new Cookie();
smCookie.Add("SMSESSION", ObtainSiteMinderSession());
Client.DefaultHeaders.Cookie.Add(smCookie);

using (var httpRequest = new HttpRequestMessage(Verbs.GET, "/LoadData/"))
{ ... }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文