473,473 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Handling WebService client side exceptions

I have a Windows C# application that is trying to invoke a remote WebService
(both mine). My problem is that trying to call the VSNet2005 generated async
methods on the service can throw exceptions that are not caught and returned
to the client.

In the "Reference.cs" file the calls are just simple
/// <remarks/>
public void NewsAsync(string authentication) {
this.NewsAsync(authentication, null);
}

/// <remarks/>
public void NewsAsync(string authentication, object userState) {
if ((this.NewsOperationCompleted == null)) {
this.NewsOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnNewsOpe rationCompleted);
}
this.InvokeAsync("News", new object[] {
authentication}, this.NewsOperationCompleted,
userState);
}

private void OnNewsOperationCompleted(object arg) {
if ((this.NewsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args
invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.NewsCompleted(this, new
NewsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}

If something is not right (the service is down for example) I'll get things
like "Socket exceptions" that are thrown and not caught and returned to my
async completedEventHandler.

My client side code is simply

community.NewsCompleted += new
NewsCompletedEventHandler(_community_NewsCompleted );
_community.NewsAsync(authString);
The completed method does get called but only after the exception is thrown
and handled (logged and exit) in my unhandled thread exception handler.

Is this working as I should expect?

Can someone advise on how/where I can catch these exceptions as they are
expected as (from time to time) the service may not be available for some
reason.

I'm using async calls here so that I can perform other UI tasks while
waiting for low important results.

Thanks
--
Neil
Apr 7 '08 #1
1 1496
Anyone listening?

Hard to believe that no one has any input on this topic. It must be
something that others have faced.

Perhaps a different discussion group would be a better place to post
questions?

--
Neil
"NeilL" wrote:
I have a Windows C# application that is trying to invoke a remote WebService
(both mine). My problem is that trying to call the VSNet2005 generated async
methods on the service can throw exceptions that are not caught and returned
to the client.

In the "Reference.cs" file the calls are just simple
/// <remarks/>
public void NewsAsync(string authentication) {
this.NewsAsync(authentication, null);
}

/// <remarks/>
public void NewsAsync(string authentication, object userState) {
if ((this.NewsOperationCompleted == null)) {
this.NewsOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnNewsOpe rationCompleted);
}
this.InvokeAsync("News", new object[] {
authentication}, this.NewsOperationCompleted,
userState);
}

private void OnNewsOperationCompleted(object arg) {
if ((this.NewsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args
invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.NewsCompleted(this, new
NewsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}

If something is not right (the service is down for example) I'll get things
like "Socket exceptions" that are thrown and not caught and returned to my
async completedEventHandler.

My client side code is simply

community.NewsCompleted += new
NewsCompletedEventHandler(_community_NewsCompleted );
_community.NewsAsync(authString);
The completed method does get called but only after the exception is thrown
and handled (logged and exit) in my unhandled thread exception handler.

Is this working as I should expect?

Can someone advise on how/where I can catch these exceptions as they are
expected as (from time to time) the service may not be available for some
reason.

I'm using async calls here so that I can perform other UI tasks while
waiting for low important results.

Thanks
--
Neil
Jun 27 '08 #2

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

Similar topics

2
by: Natalia DeBow | last post by:
Hi there, I am working on an client-server app, where the client asynchronously issues a request for the server to perform some action and the server is supposed to notify the client when the...
34
by: rawCoder | last post by:
I have read that Exception Handling is expensive performance wise ( other than Throw ) , but exactly how ? Please consider the following example ... ////////////////// Code Block 1...
11
by: Andy | last post by:
Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to...
5
by: mtv | last post by:
Hi all, I have the following code: ================================ Webservice side: public class MyWS: WebService { private myLib.DataObject curDataObject;
2
by: Riga | last post by:
Hi guys, I'm making a webservice that will be used by a pocketpc app. I want to be able to keep an instance of some things (there are 2 collections and possibly a database connection). Is there...
1
by: Mike9900 | last post by:
I want to use an interface in both the webservice and its client. For example, the web service implements an interface and then the client cast that webservice to the inteface. It seems impossible,...
1
by: Mr Bojangles | last post by:
Hi, I want a do the following: From a (client side) web form, post to server side script (I'm using Javascript but anything will do), which in turn--and this is the important bit that I...
37
by: Sweetiecakes | last post by:
Hello I'm a bit confused on how one should handle exceptions. I'm currently building an ADO.NET Windows Forms application. I've built a class for manipulating data within the database in...
6
by: Peter | last post by:
I have a WebService which returns a List of RunningReport class How do I read this XML data on the client side. How do I convert List<RunningReportfrom the WebService side to List<RunningReporton...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.