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