Hi Friends,
i have a wcf web service(.svc) and i need to write application which triggers web service after every 1 minute and find out http response status of web service, means applications calls web service and fetch web service http response status.
my main problem is i dont know how to fetch http response status code for web service ?
How i can achieve above functionality, please provide me some direction or any clue on above scenario, it will be helpful
Thanks in advance.
2 Replies - 703 Views - Last Post: 02 November 2012 - 05:25 AM
#1
how to fetch http response status code for web service ?
Posted 02 November 2012 - 04:48 AM
Replies To: how to fetch http response status code for web service ?
#2
Re: how to fetch http response status code for web service ?
Posted 02 November 2012 - 04:51 AM
You could try something like this.
Throw a HttpResponseException, which allows you to specify the response code, for example:
Throw a HttpResponseException, which allows you to specify the response code, for example:
if (authFailed) {
throw new HttpResponseException(HttpStatusCode.Unauthorized);
}
#3
Re: how to fetch http response status code for web service ?
Posted 02 November 2012 - 05:25 AM
Hi,
I have written following code.
I have created proxy class using svcutil.exe which contains ServiceClient class.
I have written timer and set 1 minute interval.
What is remaing--> i need to find out web service response, i can not change web service, but from application i need to find out http response status of web service.
main goal of this application is to find out web service is running or not.
I have written following code.
I have created proxy class using svcutil.exe which contains ServiceClient class.
I have written timer and set 1 minute interval.
What is remaing--> i need to find out web service response, i can not change web service, but from application i need to find out http response status of web service.
main goal of this application is to find out web service is running or not.
protected void Timer1_Tick(object sender, EventArgs e)
{
DateTime starttime,Endtime;
starttime = DateTime.Now;
Nullable<DateTime> response = null;
bool result=false;
try
{
ServiceClient ob1 = new ServiceClient();
response=ob1.GetStatus("para1");
Endtime = DateTime.Now;
insertintoDB(starttime, Endtime, response.ToString());
}
catch (Exception ex)
{
string response1;
Endtime = DateTime.Now;
response1 = " Message:-"+ ex.Message.ToString() + " StackTrace:- " + ex.StackTrace + " InnerException:-" + ex.InnerException + " Source:-" + ex.Source;
insertintoDB(starttime, Endtime, response1);
}
}
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|