I have a WCF service configured to use UserName custom validation using the overridden Validate () method of the System.IdentityModel.Selectors.UserNamePasswordValidator class.
All contract methods are decorated with the FaultContractAttribute attribute to indicate that a custom SOAP error is returned.
When throwing a FaultException <T>, where T is the type specified in the FaultContractAttribute attribute, everything behaves as expected, and I get a custom error in the XML response.
However, if I try to throw a FaultException <T> in the redefined Validate () method of the username authentication class, I get a general SOAP error for the following reason:
"The creator of this error did not indicate a reason."
However, if I changed the code to clear a common SOAP error, as in:
throw new FaultException("Authentication failed.");
At least I will get an "Authentication Error". in the reason element.
My questions:
- Why aren't FaultException <T> exceptions handled the same way if they are selected in Validate () because they are part of the service implementation?
- Is it possible for the exceptions thrown into the Validate () method to match the FaultContractAttribute attribute specified in the contract methods?
Any help is greatly appreciated. My own guess is that authentication occurs before the message is associated with any contract method and therefore is not related to the FaultContractAttribute, but any article that confirms this and provides a workaround will be very useful.
Tali
authentication wcf wcf-security soapfault
Tali walker
source share