473,796 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ 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.Applicat ionException

' 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 customexception class to be thrown as
wrapped inside a SoapException?
Nov 21 '06 #1
3 5629
"Tomsawyer2kin_ hotmail" <To************ *******@discuss ions.microsoft. com>
wrote in message news:6B******** *************** ***********@mic rosoft.com...
Hi,
I created a custom Exception Class as
Public Class CSTException : Inherits System.Applicat ionException

' 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 customexception class 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.Applicat ionException

' 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 customexception class 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.Applicat ionException

' 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 customexception class 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
1490
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 handled in the Windows Forms app? For example, suppose in my WebService, I have the following exception class: '\\\\\ <Serializable()> _
2
2545
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 having to integrate some Web services into the application using the existing architecture. These Web services are secured using Forms Authentication. Hence, we need to turn the default behavior of Forms Authentication (redirects to login pages, etc)...
4
4514
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 Smalltalk 6. I haven't had problems consuming other web-services but c# seems to choke with "Collection" return types. The collection (or array) is supposed to contain three instances of a custom object called PsmWsResult, which has two variable...
1
1197
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 : System.Web.Services.WebService { /// <remarks/> public abstract void newArticle(string subject, string text); }
9
6654
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 length is 642 bytes ( I have appended it to the end of this message). I suspect that the reason may have something to do with an incorrect declaration of which class to de-serialize to. In the attached code I substituted @@@@@@@ in the code below with...
1
6338
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 soap header called by using a http module. The problem Im having is I cannot seem to get the event to raise to fire off my authenticate method in the global.asax. The module is plumbed in to my web.config file Code Below:-
1
4143
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. When I attached the debugger to the process and stepped into the code it executed without error. In both cases I was running a Debug build, the only difference in the case that works is that I attached the debugger to the same exact binaries....
0
1476
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) client I get (catch) this as a SoapException (or SoapHeaderException). The SoapException contains various (string type) fields. For example, the Message fields contains the fully qualified name of the exception on the server side. The...
4
4477
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 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) client I get (catch) this as a SoapException (or SoapHeaderException). The SoapException contains...
0
9684
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...
0
9530
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
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,...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
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();...
1
4120
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
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.