Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > catch Custom SoapException

Reply
Thread Tools

catch Custom SoapException

 
 
Giulio
Guest
Posts: n/a
 
      06-06-2006
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 communication (that's not so correct, I hope you
understand what I mean).
Here is my class:

[Serializable]
public class MySoapException : SoapException, ISerializable
{
//private string tipoecc;

public MySoapException() : base()
{
//
// TODO: Add constructor logic here
//

}
public MySoapException(SerializationInfo si, StreamingContext
sc) : base(si,sc)

{

}

public string Tipoecc
{
get { return tipoecc; }
set { tipoecc = value; }
}

public override void GetObjectData(SerializationInfo si,
StreamingContext sc)
{

base.GetObjectData(si, sc);

si.AddValue("Tipoecc", tipoecc);

}


}

In this way, the new Property Tipoecc shoud be understood and
deserializad correctly by the (soap) client.
The web service throw the customized SoapException in this way:

MySoapException myexc = new MySoapException();
myexc.Tipoecc = "1";
throw myexc;

I set the value of TipoEcc = "1".
The following code is client-side:

catch (MySoapException mse)
{

//nel caso sincrono l'eccezione non Ŕ contenuta
nel campo InnerException

//la proprietÓ Tipoecc indica il valore custom con
cui Ŕ definita l'eccezione
string msg;
msg = mse.Message;
msg += "\nTipo eccezione: " +
mse.GetType().ToString();
//msg += "\nValore eccezione: " +
mse.Tipoecc.ToString();
MessageBox.Show(msg);

}

I think it should catch the custom exception, because I add the same
reference to the dll containing the implementation of the class
MySoapException.
But... it doesn't work!!!
The client catches the Exception ONLY as SoapException, and nothing
else.
I know there is another pretty way to pass custom fields or attributes
by appending a new XMLNode to the Detail property of a SoapException,
and it also works good... But I would like to know WHERE is my mistake
(or my mistakes...).
Thanks a lot.
Giulio

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Catch Custom SoapException Giulio ASP .Net Web Services 0 06-06-2006 04:16 PM
Is it possible to inherits from SoapException to create custom exception Ghislain Tanguay ASP .Net Web Services 1 01-28-2005 11:12 PM
Custom Soapexception Paul Cowan ASP .Net Web Services 1 10-22-2004 12:55 PM
Can't raise custom SoapException when TransactionOption:=TransactionOption.Required Doug ASP .Net Web Services 0 08-25-2004 02:35 AM
Creating Custom SoapException without catching each exception thrown John Harkin ASP .Net Web Services 0 08-18-2004 03:30 PM



Advertisments