473,804 Members | 3,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
<yu*********@ms n.com>

Aug 3 '08 #1
3 1355

"John Skandar" <yu*********@ms n.comwrote in message
news:15******** *************** ***********@mic rosoft.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
<yu*********@ms n.com>
Aug 3 '08 #2
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. Ar****@Arnold.c omha scritto nel messaggio
news:#T******** ******@TK2MSFTN GP02.phx.gbl...
>
"John Skandar" <yu*********@ms n.comwrote in message
news:15******** *************** ***********@mic rosoft.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
<yu*********@m sn.com>

Aug 3 '08 #3
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>
Aug 3 '08 #4

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

Similar topics

1
2983
by: Rolf | last post by:
I understand a compilation error occurs when a method that throws no exceptions is the only code in a try block. What I don't understnad is why I can specify the catching of an Exception for a method that throws no exceptions, but I cannot catch an IOException for a method that throws no exceptions? // This try/catch code complies fine, even though foo2 throws no exceptions:
15
18035
by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling (SEH) in C++ EH so that a catch (...) will catch an access violation. I don't know if other platforms support something similar. I'm wondering about how to best protect an application or library from poorly written user-defined callbacks. It...
0
2727
by: Steven Reddie | last post by:
In article <slrnbnj19j.av.juergen@monocerus.manannan.org>, Juergen Heinzl wrote: >In article <f93791bd.0309282133.650da850@posting.google.com>, Steven Reddie wrote: >> I understand that access violations aren't part of the standard C++ >> exception handling support. On Windows, a particular MSVC compiler >> option enables Microsoft's Structured Exception Handling (SEH) in C++ >> EH so that a catch (...) will catch an access violation. ...
5
2079
by: Hubert Hermanutz | last post by:
Hi, as yet i have readed in the MSDN about exception handling. The only references that i was founded, described try, catch, finally and throw objects. But I am searching about an occation to catch exceptions central, maybe, the framework call a central function of each class, when there is throw a exception. The reason is, that i do not need try, catch... blocks and therefore the sourcecode will be going to unreadable.
3
1031
by: Gary Howlett | last post by:
Hi, Am using VS 2005 C# I'm calling a webservice Asynchronously on a form used to process a login. If an exception is thrown from the webservice - if the service was called synchronously obviously the try catch works. However how do I catch exceptions when I call it Async? At the moment the exception is getting moved up to the Parent Form which I dont want. Where can I on my form capture any exceptions?
5
2234
by: Simon Tamman | last post by:
I have an object named DisasterRecovery. The Ctor of this object is this: private DisasterRecovery() { Application.ThreadException+= new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); }
1
7128
by: Simon | last post by:
Hi all, I'm having a problem creating a global exception handler in a windows service that I'm making. Another poster suggested that the way to do this was to use the CurrentDomain.UnhandledException event to catch and deal with any exception that crops up. The problem is, when I try and deliberately throw an exception in my services OnStart event handler, nothing seems to happen. By that I mean, the CurrentDomain_UnhandledException...
24
4949
by: usenet | last post by:
I am unable to catch floating exceptions (e.g. divide by 0 or 0/0) using the standard exceptions defined in stdexcept. What is the recommended way to catch such exceptions? Thanks, Song
14
3797
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain more why C++/CLI would be better to PInvoke than doing the PInvoke in C#? Because, usually in C# as you already know we use DLLImport and extern
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.