catch Custom SoapException

G

Giulio

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top