How to check whether a WCF service is running (UP) or not in ASP.NET and in C# sample code?

How to check whether a WCF service is running (UP) or not in ASP.NET and in C# sample code?





A service can be checked whether it is running or not by accessing its metadata. If it doesn’t throw exception, means, its running and up.

ASP.NET and C# Sample Code:


MetadataExchangeClient client;
                bool isServiceUp = true;
                try
                {
                    client = new MetadataExchangeClient(new Uri(“<Service address>”), MetadataExchangeClientMode.HttpGet);
                    MetadataSet metadata = client.GetMetadata();
                }
                catch (Exception ex)
                {
                    isServiceUp = false;
                }

1 comment:

  1. Metadata contains a reference that cannot be resolved:

    ReplyDelete