I'm attempting to put together a claims-aware WCF service and client.
I'm using the thinktecture Identity Server, and I've put together a console client by looking at the "Using a token with WCF/SOAP" example:
var token = GetSecurityToken();
var binding =
new WS2007FederationHttpBinding(
WSFederationHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.EstablishSecurityContext = false;
var factory =
new ChannelFactory<IService1>(
binding,
new EndpointAddress("https://localhost:44301/Service1.svc"));
factory.Credentials.SupportInteractive = false;
factory.ConfigureChannelFactory();
var service = factory.CreateChannelWithIssuedToken(token);
var result = service.GetData(42);
I have (what looks like) a valid token from the STS.
However, it throws an exception in the call to GetData
, as follows:
There was an error serializing the security key identifier. Please see the inner exception for more details.
The inner exception is as follows:
The token Serializer cannot serialize 'System.IdentityModel.Tokens.Saml2AssertionKeyIdentifierClause'. If this is a custom type you must supply a custom serializer.
The only mention of this problem that I can find is this one on the MSDN forums, but that's only slightly related.
Looking in the debugger, it appears that the endpoint behaviours include (eventually) a Saml2SecurityTokenHandler, which that other link implies is all that's needed.
What am I missing?