Catching exceptions when calling a WebServices method asynchronously

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Skandar

    Catching exceptions when calling a WebServices method asynchronously

    I've found a free WebService on the net for a currency converter and have
    created a class to use it with the WSDL tool.

    I call the WebService method asynchronously:

    converter.Conve rsionRateAsync( (Currency)fromC urrencyComboBox .SelectedIndex,
    (Currency)toCur rencyComboBox.S electedIndex);

    Where do I have to put the catch instruction?
    If I try to run the instruction above when I am not connected to the
    Internet, I receive a message with a System.Net.WebE xception exception.
    Where can I catch it?

    Thanks
    ----
    Dr. John Skandar
    <yugo_amaryl@ms n.com>

  • Mr. Arnold

    #2
    Re: Catching exceptions when calling a WebServices method asynchronously


    "John Skandar" <yugo_amaryl@ms n.comwrote in message
    news:15F99297-7A0D-44FF-BCFB-0496E590427A@mi crosoft.com...
    I've found a free WebService on the net for a currency converter and have
    created a class to use it with the WSDL tool.
    >
    I call the WebService method asynchronously:


    Try
    {
    converter.Conve rsionRateAsync( (Currency)fromC urrencyComboBox .SelectedIndex,
    (Currency)toCur rencyComboBox.S electedIndex);
    }
    catch(Excption ex)
    {
    message
    }
    >
    Where do I have to put the catch instruction?
    If I try to run the instruction above when I am not connected to the
    Internet, I receive a message with a System.Net.WebE xception exception.
    Where can I catch it?
    >
    Thanks
    ----
    Dr. John Skandar
    <yugo_amaryl@ms n.com>

    Comment

    • John Skandar

      #3
      Re: Catching exceptions when calling a WebServices method asynchronously

      Ehm... maybe if it had been so simple I wouldn't have asked...

      The problem is that the exception is not thrown by the method itself,
      because the asynchronous call just starts the operation, that is performed
      by another thread while the program continues performing its tasks. I need
      to know how to catch an exception that is thrown in that thread.

      "Mr. Arnold" <MR. Arnold@Arnold.c omha scritto nel messaggio
      news:#TMC0FY9IH A.3344@TK2MSFTN GP02.phx.gbl...
      >
      "John Skandar" <yugo_amaryl@ms n.comwrote in message
      news:15F99297-7A0D-44FF-BCFB-0496E590427A@mi crosoft.com...
      >I've found a free WebService on the net for a currency converter and have
      >created a class to use it with the WSDL tool.
      >>
      >I call the WebService method asynchronously:
      >
      >
      >
      Try
      {
      >
      converter.Conve rsionRateAsync( (Currency)fromC urrencyComboBox .SelectedIndex,
      (Currency)toCur rencyComboBox.S electedIndex);
      }
      catch(Excption ex)
      {
      message
      }
      >
      >>
      >Where do I have to put the catch instruction?
      >If I try to run the instruction above when I am not connected to the
      >Internet, I receive a message with a System.Net.WebE xception exception.
      >Where can I catch it?
      >>
      >Thanks
      >----
      >Dr. John Skandar
      ><yugo_amaryl@m sn.com>
      >
      >

      Comment

      • Chicken Little Albright

        #4
        Re: Catching exceptions when calling a WebServices method asynchronously

        John Skandar wrote:
        Ehm... maybe if it had been so simple I wouldn't have asked...
        >
        The problem is that the exception is not thrown by the method itself,
        because the asynchronous call just starts the operation, that is
        performed by another thread while the program continues performing its
        tasks. I need to know how to catch an exception that is thrown in that
        thread.
        Well, if possible, the Web service needs to return some return codes on
        success or when an exception failure has be thrown by the Web service on
        an asynchronous call to the Web service that the client can check. It's
        not going to be business as usual as in a synchronous call to Web
        service is made by a client.

        <http://it.toolbox.com/blogs/distributed-systems/errors-exceptions-and-asynchronous-web-services-15328>

        Comment

        Working...