This post originated from an RSS feed registered with .NET Buzz
by Jeff Key.
Original Post: The Devil is in the Detail
Feed Title: Jeff Key
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/jkey/Rss.aspx
Feed Description: Topics revolve around .NET and the Windows platform.
I've been working with Web Service Enhancements (WSE) 2.0 technology preview for a few weeks and I love it. If SoapService/SoapClient and soap.tcp indicate the direction we're heading toward Indigo, then sign me up.
While working on the exception management infrastructure for a web service-enabled application, I ran into an interesting situation I hope will either be documented better (if it's by design) or fixed by the time it's RTM. I couldn't find any information regarding it on the internet, so I thought I'd toss out something for Google to swallow up. Note: I haven't tested this with WSE 1.0 or ASP.NET's WebMethods framework, so there's a chance the issue is not in WSE 2.0 TP.
One of the overloaded ctors for SoapException has a “detail” parameter of type XmlNode. I had created an XML node with additional info and was passing it in to the ctor. After throwing and subsequently catching the SoapException in the caller, the Detail property was null. I confirmed that, before throwing the exception in the web service, the Detail property was set.
The documentation for SoapException.Detail states:
In building an XmlNode for the Detail property, the Name and Namespace properties of DetailElementName can be used to ensure consistency with the SOAP specification. [Emphasis mine.]
It turns out that you must use the values represented by the Name and Namespace properties of DetailElementName or the Detail node is lost before it's received by the caller.