tags:

views:

22

answers:

1

I am building a tool for validating if all the touchpoints (DB connection strings, mail servers, web services, WCF services, etc.) used by a set of applications are accessible after a disaster recovery migration to an off-site location.

The tool must check whether a given net.tcp endpoint address is valid and accessible, without generating a client proxy, and without regard to the binding or behavior used by the actual WCF client. The tool does not need to invoke any service method, and will only be run by system administrators using highly privileged domain credentials.

It is easy to do this for HTTP-based services:

hwrRequest = (HttpWebRequest)WebRequest.Create(i_WebServiceUrl);
hwrRequest.Timeout = i_nTimeoutSeconds * 1000;
hwrResponse = (HttpWebResponse)hwrRequest.GetResponse();
if (hwrResponse.StatusCode == HttpStatusCode.OK)
:
:

Is there an equivalent technique for WCF net.tcp services?

+1  A: 

First of all, why do you expect your WebRequest code to work? If the service isn't generating metadata, or is otherwise not responding to an HTTP GET verb, then your response will time out.

I recommend creating an administrative service contract and implementing it in all of your services. You may simply want to add a Ping() method to that contract, but you may also decide to add other methods.

John Saunders
Thanks for the response John. Yes, I wish we could have an admin contract with a Ping() method in every web/WCF service, but there are dozens of services of varying ages, and this would be a major task. All the new services have Ping() and PingDependencies() methods. I was hoping WCF had a primitive ping facility for ensuring an endpoint was valid and alive.Also, the WebRequest code above does work for all our HTTP-based WCF services. It returns the standard "You have created a service" page. All the services provide metadata so they can be tested using the WCF Test Client.
Simon Chadwick