Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exception is thrown if a web service I'm using times out?

I'm calling a .NET 2.0 web service within my existing .NET 2.0 web service. I would like to know what exception is thrown from the web method if a timeout happens. I have set the web service timeout to some lower value than the default 90 seconds and I want to add business logic if timeout happens.

Is [System.Net.WebException][1] the exception I should be looking at?

like image 911
BT. Avatar asked Mar 18 '10 15:03

BT.


People also ask

How do you handle timeout in Web services?

You can control the connection and socket timeout of the loading of the WSDL definition by setting enable-wsdl-discovery-timeouts . Use the value -1 to use the default of the underlying infrastructure. Use the value 0 to disable the timeouts. Use a positive integer to specify a timeout in milliseconds.

How do I fix timeout exception?

Solution. You can manually increase the wait time by hit-and-trial. If the problem persists for a longer period of time, there may be some other issue and you should continue onto the next solution. You can explicitly add wait by using JavaScript Executor.

How do you handle timeout in Java?

// Set SO_TIMEOUT for five seconds MyServerSocket. setSoTimeout(5000); Once the length for the timeout is set, any blocking operation will cause an InterruptedIOException to be thrown. For example, a DatagramSocket that failed to receive packets when the receive() method is called, would throw an exception.

What is timeout exception in C#?

The TimeoutException class can specify a message to describe the source of the exception. When a method throws this exception, the message is usually "The timeout provided has expired and the operation has not been completed." This class is used, for example, by the ServiceController class's WaitForStatus member.


2 Answers

This kind of depends on which "version" of web services you are using.

Using WCF, you will actually get a TimeoutException. You should generally also handle CommunicationException if you are attempting to handle timeouts. Sometimes I've also seen FaultException, although that technically shouldn't happen (but it does anyway once in a while). FaultException is a descendant of CommunicationException so you don't need to handle it separately, it's just useful to know that it might occur.

In ASMX, you will usually get a wrapped SoapException for which you need to check the InnerException property to see what really went wrong.

Using WSE, you'll see yet another exception, ResponseProcessingException, for which again you must check the InnerException for details.

like image 120
Aaronaught Avatar answered Oct 13 '22 00:10

Aaronaught


You should be looking for a TimeoutException:

The exception that is thrown when the time allotted for a process or operation has expired.

like image 43
Andrew Hare Avatar answered Oct 12 '22 23:10

Andrew Hare