How to deal with timeout when accessing a web service?

How to implement timeout and retry while accessing a web service before throwing an error?

  • I am developing a WP8 application. I created a web service on out-systems and then I am calling those web service methods in my app: ServiceReference1.WebServiceClient ws = new WebServiceClient(); ws.FetchInboxAsync(EmailId); Now what I want is 10 seconds timeout while trying to access the web service and retry 3 times before throwing an error but I am not sure how to achieve this.

  • Answer:

    WebServiceClient is no standard class which exists in WP8. You will have to provide details about the connection layer you are using. I assume you are ussint httpWebRequest for the connection. In this case, you can view this thread for details on how to define the timeout. After 3 timeouts you will then have to return an exception or error message. http://stackoverflow.com/questions/15038875/how-to-set-timeout-for-httpwebrequest-in-windows-phone-8-app

rituraj346 at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.