Jeff Atwood在前段时间发布了an interesting aerticle关于此主题。虽然.NET异常转换为与大多数其他工具包兼容的SoapFault,但故障信息并不是很好。为此,文章的conlusion是.NET Web服务不乱扔很好异常消息,你应该添加额外的信息:
Private Sub WebServiceExceptionHandler(ByVal ex As Exception)
Dim ueh As New AspUnhandledExceptionHandler
ueh.HandleException(ex)
'-- Build the detail element of the SOAP fault.
Dim doc As New System.Xml.XmlDocument
Dim node As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _
SoapException.DetailElementName.Name, _
SoapException.DetailElementName.Namespace)
'-- append our error detail string to the SOAP detail element
Dim details As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _
"ExceptionInfo", _
SoapException.DetailElementName.Namespace)
details.InnerText = ueh.ExceptionToString(ex)
node.AppendChild(details)
'-- re-throw the exception so we can package additional info
Throw New SoapException("Unhandled Exception: " & ex.Message, _
SoapException.ClientFaultCode, _
Context.Request.Url.ToString, node)
End Sub
更多信息为什么soapfaults更好in this question。
我真的很想知道为什么这是投下来的票?这完全相关。 – 2008-09-18 14:51:12