Getting XML Namespace error while reading a SAML2 token

jacob126

New Member
I have a valid SAML 2 token from my application IdP:When I try to read it using WIF code as below I get the following error:\[quote\] Cannot read the token from the 'Response' element with the 'urn:oasis:names:tc:SAML:2.0:protocol' namespace for BinarySecretSecurityToken, with a '' ValueType. If this element is expected to be valid, ensure that security is configured to consume tokens with the name, namespace and value type specified.\[/quote\]Here is the code I am using with a comment showing where it fails\[code\] string certPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SSO.cer"; X509Certificate2 cert = new X509Certificate2(certPath); //X509Certificate2 cert = new X509Certificate2(certPath, "LetMeIn!"); // Open the SAML string samlPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SAML.xml"; string samlRaw = File.OpenText(samlPath).ReadToEnd(); XmlReader rdr = XmlReader.Create(samlPath); List<System.IdentityModel.Tokens.SecurityToken> tokens = new List<System.IdentityModel.Tokens.SecurityToken>(); var token = new X509SecurityToken(cert); tokens.Add(token); SecurityTokenResolver resolver = SecurityTokenResolver.CreateDefaultSecurityTokenResolver( new System.Collections.ObjectModel.ReadOnlyCollection<SecurityToken>(tokens), true); //Fails on next line! SecurityToken securityToken = System.ServiceModel.Security.WSSecurityTokenSerializer.DefaultInstance.ReadToken(rdr, resolver); SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;\[/code\]The problem is an XML namespace exception but I don't know how to 'ensure that security is configured to consume tokens with the name, namespace and value type specified'Can someone point me in the right direction please?
 
Back
Top