473,473 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Throwing custom exceptions from Web Services

Hi,

I an using Web Services as my business layer and wanted to throw custom
exceptions from the web method based on some business logic.

Now, when I make a custom exception class bu inheriting from SoapException
class and throw it from a web method. I get below mentioned error message
when I run that method:

"System.InvalidOperationException: WebService.MyException cannot be
serialized because it does not have a default public constructor."

Can someone help?

Thanks,
Deepak Vij
May 25 '07 #1
5 4281
"Deepak Vij" <de********@nospam.nospamwrote in message
news:59**********************************@microsof t.com...
Hi,

I an using Web Services as my business layer and wanted to throw custom
exceptions from the web method based on some business logic.

Now, when I make a custom exception class bu inheriting from SoapException
class and throw it from a web method. I get below mentioned error message
when I run that method:

"System.InvalidOperationException: WebService.MyException cannot be
serialized because it does not have a default public constructor."

Can someone help?
Add:

public MyException()
{
}
--
John Saunders [MVP]
May 25 '07 #2
Sorry, could not understand. can you pelase elaborate?
--
Thanks,
Deepak Vij
Technical Manager
WNS NA Inc., NA
de********@firstmagnus.com
"John Saunders [MVP]" wrote:
"Deepak Vij" <de********@nospam.nospamwrote in message
news:59**********************************@microsof t.com...
Hi,

I an using Web Services as my business layer and wanted to throw custom
exceptions from the web method based on some business logic.

Now, when I make a custom exception class bu inheriting from SoapException
class and throw it from a web method. I get below mentioned error message
when I run that method:

"System.InvalidOperationException: WebService.MyException cannot be
serialized because it does not have a default public constructor."

Can someone help?

Add:

public MyException()
{
}
--
John Saunders [MVP]
May 25 '07 #3
"Deepak Vij" <de********@nospam.nospamwrote in message
news:04**********************************@microsof t.com...
Sorry, could not understand. can you pelase elaborate?
The error message says that you need to add a parameterless constructor. The
code I posted is a parameterless constructor. Add it.
--
John Saunders [MVP]
May 27 '07 #4
Hi Deepak,

As the error message indicate, your custom exception class doesn't have a
default constructor(parameterless constructor), is this the actual case for
your scenario?

============
"System.InvalidOperationException: WebService.MyException cannot be
serialized because it does not have a default public constructor."
============

also, here are some other articles discussing on webservice exception
handling or customization:

http://msdn2.microsoft.com/en-us/lib...tk(VS.71).aspx

http://support.microsoft.com/kb/833379
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
May 28 '07 #5
Hi Deepak,

How are you doing on this issue, have you got any progress? If there is
still anything we can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
May 30 '07 #6

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

Similar topics

5
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the...
21
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
1
by: Vinoth Kumar | last post by:
Hi All, I have a problem in throwing custom exceptions from a webservice method. The custom exception is being converted into soapexception in the webservice client. only the custom exception...
0
by: Giulio | last post by:
Hi programmers, I'm quite new in this blog, I have a question concerning web services Soap Exceptions: I created a class MySoapException derived from SoapException, I add the references both...
2
by: Anthony Biondo Jr | last post by:
I was wondering how to handle an error in a web service. If our web service encounters a connection error or any other error what is the best practice for returning an error? Do you return a...
3
by: Tomsawyer2kin_hotmail | last post by:
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...
0
by: mlaanti | last post by:
Hello, I asked this couple weeks ago but didn't get answers. So, does Silverlight 2 Beta 2 understand anything about WCF's Exceptions? Trying to passing a fault reason as Exceptions...
3
by: Kevinst | last post by:
Hello, I have a c# com object that exposes several methods. This com object is to be used in vbscripts as well as vba scripts. In my application error handling is done by throwing different...
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...
1
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...
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...
1
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...
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
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...

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.