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

Home Posts Topics Members FAQ

Custom Exception gets wrapped as soap exception

Hi,
I created a custom Exception Class as
Public Class CSTException : Inherits System.ApplicationException

' required to over ride the base class method
Sub New(ByVal ExceptionCode As AppExCodes)
MyBase.New(CStr(ExceptionCode))
End Sub
end class

in my WS i have a reference to the class and i throw a CSTException.

In my client side i have the reference to the CSTException class too.
I use a try catch as

try
....
catch ex as CSTException
....
end try
Now on my client side i get the ex as a SoapException obj . and the
ex.Message as
"Server was unable to process the request ---257" where 257 is my AppExCode.
I was expecting ex.Message to be "257".

Is theer any way i can prevent my customexceptionclass to be thrown as
wrapped inside a SoapException?
Nov 21 '06 #1
3 5610
"Tomsawyer2kin_hotmail" <To*******************@discussions.microsoft.com >
wrote in message news:6B**********************************@microsof t.com...
Hi,
I created a custom Exception Class as
Public Class CSTException : Inherits System.ApplicationException

' required to over ride the base class method
Sub New(ByVal ExceptionCode As AppExCodes)
MyBase.New(CStr(ExceptionCode))
End Sub
end class

in my WS i have a reference to the class and i throw a CSTException.

In my client side i have the reference to the CSTException class too.
I use a try catch as

try
...
catch ex as CSTException
...
end try
Now on my client side i get the ex as a SoapException obj . and the
ex.Message as
"Server was unable to process the request ---257" where 257 is my
AppExCode.
I was expecting ex.Message to be "257".

Is theer any way i can prevent my customexceptionclass to be thrown as
wrapped inside a SoapException?
No. This is by design. There's no such thing as an Exception in Web
Services. There are Soap Faults. Since .NET gives you no way to map
exceptions into faults, all unhandled exceptions are translated into Soap
Faults.

The best you can do involves manually creating your WSDL file and adding
faults. Then, when you need to throw an exception corresponding to one of
the faults, you create the body of the fault and place it in the Detail
property of the SoapException, then throw it.

A .NET client will still receive a SoapException on the other end, but will
have still have the fault body in the Detail property. If you like, your
custom client code can look at the Detail and throw a custom exception
(passing the original as InnerException, please).

John
Nov 21 '06 #2
This is indeed possible (to retrive the original exception type) on the
Client side.
But as suggested elsewhere, by design you should not bother with this. As a
service potentially could be consumed by a Java client, it makes no sense to
throw .NET specific exceptions on the client side.

However - if you are in control of both C/S, you can implement a socalled
SoapException and attribute that to your methods. This wil allow the
clientside proxy to (re)throw the original exception type to you.

If you insist - I can supply the source for this. Else have a look at MSDN
for this here:
http://msdn.microsoft.com/library/de...classtopic.asp
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"Tomsawyer2kin_hotmail" wrote:
Hi,
I created a custom Exception Class as
Public Class CSTException : Inherits System.ApplicationException

' required to over ride the base class method
Sub New(ByVal ExceptionCode As AppExCodes)
MyBase.New(CStr(ExceptionCode))
End Sub
end class

in my WS i have a reference to the class and i throw a CSTException.

In my client side i have the reference to the CSTException class too.
I use a try catch as

try
...
catch ex as CSTException
...
end try
Now on my client side i get the ex as a SoapException obj . and the
ex.Message as
"Server was unable to process the request ---257" where 257 is my AppExCode.
I was expecting ex.Message to be "257".

Is theer any way i can prevent my customexceptionclass to be thrown as
wrapped inside a SoapException?

Nov 23 '06 #3
A severe typo there.
I of-course ment SoapExtension, NOT SoapException!
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"Claus Konrad [MCSD]" wrote:
This is indeed possible (to retrive the original exception type) on the
Client side.
But as suggested elsewhere, by design you should not bother with this. As a
service potentially could be consumed by a Java client, it makes no sense to
throw .NET specific exceptions on the client side.

However - if you are in control of both C/S, you can implement a socalled
SoapException and attribute that to your methods. This wil allow the
clientside proxy to (re)throw the original exception type to you.

If you insist - I can supply the source for this. Else have a look at MSDN
for this here:
http://msdn.microsoft.com/library/de...classtopic.asp
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"Tomsawyer2kin_hotmail" wrote:
Hi,
I created a custom Exception Class as
Public Class CSTException : Inherits System.ApplicationException

' required to over ride the base class method
Sub New(ByVal ExceptionCode As AppExCodes)
MyBase.New(CStr(ExceptionCode))
End Sub
end class

in my WS i have a reference to the class and i throw a CSTException.

In my client side i have the reference to the CSTException class too.
I use a try catch as

try
...
catch ex as CSTException
...
end try
Now on my client side i get the ex as a SoapException obj . and the
ex.Message as
"Server was unable to process the request ---257" where 257 is my AppExCode.
I was expecting ex.Message to be "257".

Is theer any way i can prevent my customexceptionclass to be thrown as
wrapped inside a SoapException?
Nov 24 '06 #4

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

Similar topics

1
by: Chris Dunaway | last post by:
I'm creating a Web service and a Windows Forms application to consume it. My question is about throwing a custom exception inside the WebService. Can that be done, and can the custom web service be...
2
by: Matt | last post by:
Hello all, The app we are working on uses custom errors extensively to provide friendly error pages to users whilst logging the actual exceptions behind the scenes. However.... We are now...
4
by: hellrazor | last post by:
Hi there, I'm trying to consume a web-service that is supposed to return a collection of a custom object. The web-service was not created with C# or VS.net. It was created with IBM VisualAge...
1
by: Dan Diephouse | last post by:
I'm writing an extension with WSE 2.0 to send/receive soap messages over Jabber. I've generated a server stub which I've implemented: public abstract class ArticleService :...
9
by: MR | last post by:
I get the following Exception "The data at the root level is invalid. Line 1, position 642" whenever I try to deserialize an incoming SOAP message. The incoming message is formed well and its...
1
by: Stu | last post by:
Hi, Im using vis studio 2003 and I think wse is out of the question as clients could be using java which doesnt support it. So I managed to find some code which allows you to develop a custom...
1
by: David Herbst | last post by:
Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000 Server sp4. My custom exception formatter fails with a "Unable to handle exception: 'LoggingExceptionHandler'." exception. ...
0
by: Nol | last post by:
Hi all, My webservice throws an exception, which is translated into a soap Fault in the soap message body. See below for the actual message format as it is send by the server. On the (dotNet)...
4
by: Nol de Wit | last post by:
(this is a re-post of a message I've posted last friday, but now from my MSDN subscription account, hoping MSDN support will pick this up...) Hi all, My webservice throws an exception, which...
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
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
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...
0
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,...
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: 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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.