I have a WCF server with a custom UserNamePasswordValidator.
public class CustomUserNameValidator : UserNamePasswordValidator
{
private readonly string m_userName;
private readonly string m_password;
/// <summary>
/// CustomUserNameValidator
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
public CustomUserNameValidator(string userName, string password)
{
m_userName = userName;
m_password = password;
}
/// <summary>
/// Validate
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
public override void Validate(string userName, string password)
{
if (!(userName == m_userName && password == m_password))
{
throw new FaultException("Authentication failed!");
}
}
}
On the client side, I call a function with wrong credentials added to the proxy
try
{
return service.GetServiceDescription();
}
catch (FaultException)
{
}
catch (TimeoutException)
{
}
In the debugger of the server I can see, that the FaultException is thrown. But the client will never receive this exception. It will end up in a TimeoutException on client side.
If I use the right credentials, the function an server side will be called and ervery thing works well, so the wcf is working correct.
But what do I have to do, that the FaultException will be thrown to the client, so that I can realize, that the credentials are wrong on client side?
UPDATE: It works, when I use the WSHttpBinding, the I am able to catch a MessageSecurityException. But when I am using WSDualHttpBinding and a dual channel, then I am running into a time out.