473,545 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ 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.Invalid OperationExcept ion: WebService.MyEx ception cannot be
serialized because it does not have a default public constructor."

Can someone help?

Thanks,
Deepak Vij
May 25 '07 #1
5 4287
"Deepak Vij" <de********@nos pam.nospamwrote in message
news:59******** *************** ***********@mic rosoft.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.Invalid OperationExcept ion: WebService.MyEx ception 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********@firs tmagnus.com
"John Saunders [MVP]" wrote:
"Deepak Vij" <de********@nos pam.nospamwrote in message
news:59******** *************** ***********@mic rosoft.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.Invalid OperationExcept ion: WebService.MyEx ception 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********@nos pam.nospamwrote in message
news:04******** *************** ***********@mic rosoft.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(par ameterless constructor), is this the actual case for
your scenario?

============
"System.Invalid OperationExcept ion: WebService.MyEx ception 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
4665
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 former, i have a few questions that need to be answered. 1) What about functions that need to return a value regardless of the error. How can they...
21
4392
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 can we avoid throwing exceptions? If we already have an abject witch was initialized wit _create_ we will be forced to call create in copy...
40
13473
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
1
3195
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 message is present in the soapexception . Is there any way to get the exact custom exception instead of soapexception? Thanks in advance
0
1479
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 server-side and client-side, and I tried to implement correctly serialization, I mean, the "ability" of a class to be used through a web services...
2
1897
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 blank result with an error attached or is there some other way to do this? thanks, Anthony
3
5621
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 AppExCodes) MyBase.New(CStr(ExceptionCode)) End Sub end class
0
1118
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 parameters does not appear to Silverlight client. So, could some please tell how to manage this kind of issue?
3
3417
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 types of custom exceptions. The problem is that when theses exceptions are caught by the vbscript the type of the exception is unknown. Therefore I...
0
7478
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...
0
7410
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...
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7773
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...
0
5984
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...
1
5343
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...
0
3466
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...
1
1901
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
1
1025
muto222
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.