Click here to Skip to main content
15,899,679 members

Comments by Naveen Singh (Top 62 by date)

Naveen Singh 3-Aug-16 5:18am View    
as of same i achieved for web API too.
Naveen Singh 3-Aug-16 5:17am View    
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 8-Nov-15 6:41am View    
hi Krunal thanks for yours response but i am getting :-

System.Xml.XmlException' occurred in System.Xml.dll

error.
Naveen Singh 8-Nov-15 5:22am View    
hi suvendu thanks for yours response but i am getting :-

System.Xml.XmlException' occurred in System.Xml.dll

error.
Naveen Singh 21-May-15 6:58am View    
doesnt work for me :(