I would like to know why this doesn't work too, as it is stalling a piece of
a project I'm working on. MS where are you?
Eirik M.
> If you examine the SoapExeption contructor there is one that takes a
> System.Exception (inner exception) as a parameter. What you could think is
[quoted text clipped - 9 lines]
>
> /Henke
Its not in the SOAP spec for the InnerException property to be returned.
You will have to implement a custom solution. I did this and it works fine.
You basically create a function that returns an XmlNode and create your
fault details there. Then when you throw a SoapException, you pass the
method call the XmlNode and the soap exception.
This will return your SOAP fault properly. Now to get the values on the
client side, you will have to manually create a method to return your
details either as an XmlDocument, XmlNode, or specifically make properties
that correspond to your InnerException elements and parse them out upon
instantiation of your Proxy class. When your Proxy gens a SoapException,
pass it to your custom handler.
As an example, for a custom innnerexception property
"InnerExceptionMessage", when you encounter the SoapException, pass it to
your exception handler
catch(System.Web.Services.Protocols.SoapException se){
myExceptionHandler myeh = new myExceptionHandler(se);
string myInnerExceptionMessage = myeh.InnerExceptionMessage;
}
Your exception handler constructor would look something like this...
public myExceptionHandler(SoapException se):base (se.Message, se.Code,
se.Actor, se.Detail, se.InnerException) {
XmlNode nMessage = null;
nMessage = se.Detail.SelectSingleNode("InnerExceptionMessage");
if(nMessage != null){
sMsg = nMessage.InnerText;
if (sMsg != null)
this.ieMsg= sMsg;
}
}
note the "ieMsg" is declared as a private string to return from your custom
property of your myExceptionHandler class...
public string InnerExceptionMessage {
get {
return ieMsg;
}
}
Hope this helps.
--------------------------------------------------------
> If you examine the SoapExeption contructor there is one that takes a
> System.Exception (inner exception) as a parameter. What you could think is
[quoted text clipped - 9 lines]
>
> /Henke
Eirik M. - 17 Sep 2003 20:01 GMT
> Its not in the SOAP spec for the InnerException property to be returned.
> You will have to implement a custom solution. I did this and it works fine.
> You basically create a function that returns an XmlNode and create your
> fault details there. Then when you throw a SoapException, you pass the
> method call the XmlNode and the soap exception.
Can you elaborate on this? Do you mean "catch a SoapException"?
Eirik M.
> This will return your SOAP fault properly. Now to get the values on the
> client side, you will have to manually create a method to return your
[quoted text clipped - 51 lines]
> >
> > /Henke
CSharpTooth - 21 Sep 2003 04:03 GMT
Yes,
When you create your Web Methods in your Web Service, and an error occurs,
use the try{} catch(Exception e){} block to catch the exception, then throw
a new soap exception.
Once you throw the new Soap Exception, you can create a custom method to
create the InnerException details as a SOAP Fault XmlNode, then pass that
into the overloaded method for SoapException.
When the exception is found and you trap, then rethrow, your web proxy that
is created from the Web Service wsdl file will then generate a
(SoapException se) on the client side that you can trap as:
try{
your code...
}
catch(SoapException se){
your code...
}
catch(Exception e){
your code...
}
Make sure you put the catch(SoapException se) before the catch(Exception e)
as Exception will catch all generic and subclassed exceptions (including
SoapException).
> > Its not in the SOAP spec for the InnerException property to be returned.
> > You will have to implement a custom solution. I did this and it works
[quoted text clipped - 67 lines]
> > >
> > > /Henke