Pinging WCF Services

What is the most efficient way to check if the WCF service is available. (Pinging) Assume that it is configuration independent.

I prefer not to modify Service Contracts using the IsAlive () method. Ideally, I would expect WCF support to be supported. Otherwise, our solution is carried out by adding the service "ServiceAdministration", which is located in the same process as the above service. ServiceAdministration has a link to ServiceHost and can check its status.

+6
wcf
source share
3 answers

The two things I do are telnet checking to make sure the WCF process is open.

telnet host 8080 

The second thing I do is always add the IsAlive method to my WCF contract, so there is an easy way to call to verify that the service host is working properly.

 public bool IsAlive() { return true; } 
+18
source share

Sipwiz's answer is absolutely the same as I would do - check out the specific method you can call to get a response from your WCF service.

However, be aware of some limitations here: it will only prove that your customer can call your service code. That may be enough for you - great. But, in my experience, the real problem is that other service methods are more likely to access other services and / or databases or what you should actually be doing. These systems may also be inaccessible / inaccessible, in which case your .IsAlive() will correctly .IsAlive() “everything is fine for this service”, but when you go to actually call one of the “real” methods of work, it can very much suffer a failure.

Basically, if you really want to know if all of your service methods will be called right now, you will need to call each of them using some test data or find another way to find out if their backend systems are alive. But such an .IsEverythingAlive() method can turn into a completely monster and take quite a long time to complete and is still not really useful ... even if this method returns “everything is fine”, after a microsecond later, when your real call comes, one of the backend systems may be dead.

So, while .IsAlive () gives you a quick and easy way to determine if you can really achieve your own service, it really is not a guarantee that your real call will succeed - you just cannot check it ... you must always assume that he will fail and deal with the possibility of failure and / or timeout.

Mark

+4
source share

If this is a “published” WCF service, you should be able to request a WSDL scheme, which is usually dynamically generated by the service. Therefore, if the WSDL scheme returns a valid response, the service must be available. If this is your service, you can guarantee it, the third-party service may not publish the service description, or it may be a non-dynamic WSDL.

So, if your service was /service.svc, try the HTTP request / service.svc? Wsdl. If you receive a valid 200 response, the service must be available.

Again, this is not ideal when you are not in control of the implementation of the service.

-Jeff

+1
source share

All Articles