locked
Web Service should response. RRS feed

  • Question

  • Hello.

    Im looking to create a Web Service, that will host some methods. I will call these methods trough mobile devices or even computer, but in this local, Internet can be down a lot. So let's consider the following scenario:
    - My mobile call WebService.Method1().

    I need to wrap on my app, that if connection lost, timeout or something, i need a response and if Method1() doesnt occur, timeout, i need a response either.

    How can i achieve that? I hope someone could point me.

    Regards,


    If you get your question answered, please come back and Alternate TextMark As Answer.
    Web Developer

    Tuesday, June 3, 2014 1:38 PM

Answers

  • That is all going to have to be handled client side.  Depends upon the language you're using but most languages have exception handling so that is what you'll need to do.  You'll need to wrap calls to the various service methods in a try-catch (or equivalent) and handle network exceptions.  You can wrap this up in a wrapper type so the calling code doesn't care but you're still going to want to expose the error somehow because only the calling code knows how to respond.  For example a connection lost error might cause a feature to be temporarily unavailable but a timeout may just need to be tried again.  Therefore I don't know that you gain anything by wrapping the service call (other than to cut down on the wrapper code).

    In C# you might do this:

    try
    {
       serviceMethod();
    } catch (IOException)
    {
       //Network error?
    } catch (TimeoutException)
    {
       //Timeout, maybe retry
    }

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Tuesday, June 3, 2014 2:02 PM