473,508 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to throw a exception if something goes wrong?

I have a Webservice which calls another component sitting on different
machine

Machine A Machine B
Webservice ------------------->Component

Due to network problem when webservice calls component it kinds of
hung. I want to give a timeout to it and if within that timeout
period nothing comes back just throw exception. Any one can give me
an idea how to accomplish it.
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #1
3 1553
You could set a timeout value for your webservice call and see if that
helps.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebServicesProtocolsWebClientProtocolCl assTimeoutTopic.asp

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"guptatushar" <gu*********@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
I have a Webservice which calls another component sitting on different
machine

Machine A Machine B
Webservice ------------------->Component

Due to network problem when webservice calls component it kinds of
hung. I want to give a timeout to it and if within that timeout
period nothing comes back just throw exception. Any one can give me
an idea how to accomplish it.
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 15 '05 #2
Thanks john for the reply, is there a way we could set the attribute
of WebMEthod so that if it dosent return in some specified time
throw an exception. I have a Webmethod somehting like this
[WebMethod]
public int GetTTMainframe1Status( out int Status)
{
int RetCode = -1;
Status = -1;
try
{
OSVC_NETWORKLib.MonitorNetworkClass MnfObj = new
OSVC_NETWORKLib.MonitorNetworkClass();
RetCode = MnfObj.Ping(0);
Status = RetCode;
}
catch(Exception ex)
{
EventLog.WriteEntry("AppMonitor",ex.ToString(),Sys tem.Diagnostics.EventLogEntryType.Error);
return Error;

}
I am having problem with Ping, when network is down. Can we set some
timeperiod to this Webmethod so that if ping gets called and
something is not returned back throw exception or just return. Any
help highly appreciated.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #3
I dont think there us as such. The timout is how long the client proxy is
prepared to wait for a reply, not how long the web method can take to
execute.

Two options spring to mind ...

Put your call in a thread within the webmethod, and time it - aborting the
thread if it doesn't return in time and returning a sensible value to
indicate failure..

Or...set the session timout value in your web.config to be 1 minute, that
should timeout your method after 60 seconds. Of course with this you will
need to put your service in its own little application.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"guptatushar" <gu*********@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
Thanks john for the reply, is there a way we could set the attribute
of WebMEthod so that if it dosent return in some specified time
throw an exception. I have a Webmethod somehting like this
[WebMethod]
public int GetTTMainframe1Status( out int Status)
{
int RetCode = -1;
Status = -1;
try
{
OSVC_NETWORKLib.MonitorNetworkClass MnfObj = new
OSVC_NETWORKLib.MonitorNetworkClass();
RetCode = MnfObj.Ping(0);
Status = RetCode;
}
catch(Exception ex)
{
EventLog.WriteEntry("AppMonitor",ex.ToString(),Sys tem.Diagnostics.EventLogEn
tryType.Error); return Error;

}
I am having problem with Ping, when network is down. Can we set some
timeperiod to this Webmethod so that if ping gets called and
something is not returned back throw exception or just return. Any
help highly appreciated.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1139
by: Lasse Vågsæther Karlsen | last post by:
From the book by Jeffrey Richter: throw; will not change the origin of the exception, whereas throw ex; will change the origin of the exception to this statement. When I try the following...
6
2002
by: Fir5tSight | last post by:
Hi, What does "throw" do? I understand that it throws an error when certain exceptional situation happens. My guess is that this *ignores* the error and *continues* so that it prevents the...
4
9094
by: Oscar | last post by:
Hi, I got a webservie that supply users with binary files based on a parameter id. The method is void and I stream the file by: HttpContext.Current.Response.ContentType = "application/xxx";...
6
1944
by: jason.cipriani | last post by:
Consider this program, which defines a template class who's template parameter is the type of an exception that can be thrown by members of the class: === BEGIN EXAMPLE === #include...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.