Best practices for validating wcf endpoint on client with/without SSL/TLS

I tried to catch all exception of wcf sercue with/without SSL/TLS or endpoint, something like this:

try
        {
            ServiceReference.ServiceClient serviceClient = new ChartLogicServiceClient();
            serviceClient.Open();
            serviceClient.Login("", "", "");
        }
        catch (SecurityNegotiationException negotiationException)
        {
            // Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost'.
            throw;
        }
        catch (ArgumentException argumentException)
        {
            // transport wrong config : The provided URI scheme 'https' is invalid; expected 'http'.
            //if (argumentException.Message == "The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via")
            throw;
        }
        catch (MessageSecurityException messageSecurityException)
        {
            // transport wrong config: The HTTP request was forbidden with client authentication scheme 'Anonymous'.
            //- HTTP Request Error
            if (messageSecurityException.InnerException.Message == "The remote server returned an error: (403) Forbidden.")
            {
                throw;
            }
            else if (messageSecurityException.InnerException.Message == "The remote server returned an error: (404) Forbidden.")
            {
                throw;
            }
        }
        catch (EndpointNotFoundException endpointNotFoundException)
        {
            // no endpoint was found or IIS on server was turned off

        }

Can i check the available of wcf service without calling any method ( i tried Open() but not work at all)? Not sure i catch all cases of exception from WCF service? My purpose is if client got wcf exception with SSL/TSL or no endpoint, i should run a small utility console to fix app.config on client to map with wcf endpoint and . I really need your suggestions. Thanks

Answers


You can always try to connect to the URL of the service and check the response code. Maybe not the best way, but it should work. e.g.

GET mysite/myservice.svc

and check for the HTTP status code.


Need Your Help

sharing methods across 2 service layers

asp.net-mvc-3 entity-framework service-layer

I'm developing an application with MVC3 and Entity Framework. I have service layers for two entities that have one similarity.

How to pass data from server to android app: REST vs Sockets

java android sockets rest

I'am writing an android app that needs some data from the server. I am also writing the server side in Java.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.