tags:

views:

11

answers:

0

I have a set of WCF services that I am integrating with, I can not change them in any way because they are provided by a third party. I use a username/password scheme to authenticate with the services.

If the services are not available I get an exception (EndPointNotFoundException) from the SecurityTokenProvider class that I can not catch. I understand why the exception is being thrown, I just need to know how I can handle it so that I can gracefully handle the errors in the user interface.

Is there a way I can catch this exception or a better way to handle this scenario?

The Exception

The exception is thrown from System.IdentityModel.Selectors.SecurityTokenProvider : GetToken( TimeSpan timeout )

public SecurityToken GetToken(TimeSpan timeout) 
{
    SecurityToken token = this.GetTokenCore(timeout); 
    if (token == null)
    {
        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.TokenProviderUnableToGetToken, this)));
    } 
    return token;
} 

The channel open part

When I open the channel I have it wrapped in exception handling, but none of it seems to trap the SecurityToken exception. I am using the ExceptionHandlingProxyWrapperBase

try
{
    this.Open();
} catch( EndpointNotFoundException epnfe )
{
    // Handle the exception
} catch( Exception e )
{
    // Handle the exception
}