HighTechTalks DotNet Forums  

Catch Custom SoapException

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss Catch Custom SoapException in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Giulio
 
Posts: n/a

Default Catch Custom SoapException - 06-06-2006 , 11:16 AM






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 Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.