Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I want to create a application which will monitor the status of web services and API if it stopped or not up i will do something.I want to use .net core for this but the dependent library are not available in .net core .

Can Any one please guide and help me.

What I have tried:

i have tried in c# and almost achieved what i want.
Posted
Comments
Suvendu Shekhar Giri 3-Aug-16 5:11am    
Share the list of system classes you have used in the C# app which was working correctly.
Naveen Singh 3-Aug-16 5:17am    
i have one test method in one of my web service for which i use below method to achieve the test:

private static void GetVersion()
{
var url = "http://XXXXXX/XXXXX/service.asmx/GetStatus";
string result = "";
var myRequest = (HttpWebRequest)WebRequest.Create(url);

var response = (HttpWebResponse)myRequest.GetResponse();

using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
result = sr.ReadToEnd();
sr.Close();
}
XmlDocument xd = new XmlDocument();
xd.LoadXml(result);
XmlElement xe = xd["string"];
Console.WriteLine(xe.InnerText);
Console.ReadKey();
}

and for window service i used below :

private static void WindowServiceStatusPass()
{
ConnectionOptions options =
new ConnectionOptions();
options.Username = @"xxxxx";
options.Password = "xxxxx";
ManagementScope scope =
new ManagementScope(
"\\\\xxxxxxx\\root\\cimv2", options);
scope.Connect();
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_Service WHERE Name = 'test.Service_8.0'");

ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, query);

ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject queryObj in queryCollection)
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_Service instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", queryObj["Name"]);
Console.WriteLine("Status: {0}", queryObj["Status"]);
Console.WriteLine("State: {0}", queryObj["State"]);
}

Its just the POC code but im getting what i exactly want from here
Naveen Singh 3-Aug-16 5:18am    
as of same i achieved for web API too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900