tags:

views:

373

answers:

3

Hello there,

My WCF Service is hosted under Windows Service and in case it is not running when client makes a call to its methods, client gets the EndpointNotFoundException with this message:

There was no endpoint listening...

Is there a way I can check if the WCF service is up and running before making calls to the service methods?

Thank you!

+3  A: 

Besides just calling it?

You could try pinging it, but that would just tell you that it exists and that its running, not that it's able to accept calls or anything.

UPDATE

To ping the web service you can use the Ping class from System.Net.NetworkInformation.

Joseph
Thank for your reply. Yes, I just need to check if it's up and running. How can i ping the service in my client code (asp.net website)?
inutan
@inutan I added a way to ping in my answer.
Joseph
+1  A: 

A solution may be to make a 1st 'dummy' call, if that exception is encountered conclude that it's not running.

najmeddine
A: 

You could expose the service contract as WSDL, if possible. If you can reach the WSDL page, then it's running, otherwise it's not.

Philippe