使用SAML令牌的Web服务(WSDL) [英] Using SAML token with Web Service (wsdl)
本文介绍了使用SAML令牌的Web服务(WSDL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在考虑从供应商一个.wsdl文件和.PFX。
I have been given a .wsdl file and .pfx from the provider.
我所说的IDP和获取SAML令牌。现在我需要将令牌传递给WebService的。
I call the IdP and acquire a SAML token. Now I need to pass that token to the WebService.
如何使用SAML令牌与web服务工作?
How do I use the SAML token to work with the WebService?
我使用.NET 4.5
I am using .NET 4.5
推荐答案
我能够添加标记,并得到响应以下两个职位的帮助:
I was able to add the token and get response with the help of the following two posts:
HTTP://www.noiseworks .ORG /安全性令牌服务在ASP网应用部分-2 /
http://travisspencer.com/blog/2012/01/cryptographic -operations-是-r.html
下面是我的code:
private static string serviceEndpoint = "https service endpoint";
public static void CallProviderService(SecurityToken token)
{
var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.EstablishSecurityContext = false;
binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;
var channelFactory = new ChannelFactory<ISomeProviderService>(binding, new EndpointAddress(new Uri(serviceEndpoint)));
string thumb = "mycertthumbprint";
channelFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, thumb);
channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerOrChainTrust;
channelFactory.ConfigureChannelFactory();
channelFactory.Credentials.SupportInteractive = false;
var elements = service.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
service.Endpoint.Binding = new CustomBinding(elements);
var channel = channelFactory.CreateChannelWithIssuedToken<ISomeProviderService>(token);
try
{
var response = channel.MyServiceMethod(somedataobject);
}
catch (Exception ex)
{
//log message
}
}
这篇关于使用SAML令牌的Web服务(WSDL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文