[英]How to call WCF Http Service behind SiteMinder
I am trying to call WCF 4 Http Web Services which are hosted within an ASP.NET application. 我试图调用在ASP.NET应用程序中托管的WCF 4 Http Web服务。 The Service is protected behind SiteMinder. 该服务受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. 我想知道如何以编程方式调用Web服务,更具体地说,我需要传递哪些信息才能在SiteMinder中获得授权以访问我的资源。
I am making the request from the ASP.NET application running on the same server, so I have access to the authentication cookie. 我从同一台服务器上运行的ASP.NET应用程序发出请求,因此我可以访问身份验证cookie。
First obtain the SiteMinder authentication token like so: 首先获取SiteMinder身份验证令牌,如下所示:
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): 然后传递此令牌与您的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/"))
{ ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.