Ciao ho la necessita di serializzare gli errori che mi puo' sfornare una Serie di WebServices da me realizzati.
Ho seguito Passo Passo la guida MSDN a riguardo e sono arrivato alla creazione di una classe per la gestione delle SOAP Exception in questo modo :
A questo punto all' interno di un WebServices implemento un blocco Try Catch, dove l' eccezione sarà una SoapException di questo tipocodice:Imports System Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Xml.Serialization Imports System.Xml Public Class clsThrowSoapException Inherits WebService Public Sub myThrow() 'Dettaglio di Default dell' elemento SOAP Dim doc As New System.Xml.XmlDocument Dim node As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ SoapException.DetailElementName.Name, _ SoapException.DetailElementName.Namespace) 'Dettaglio dell' errore Dim details As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ "mySpecialInfo1", "http://www.globuscosmos.com/") Dim details2 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, _ "mySpecialInfo2", "http://www.globuscosmos.com/") Dim attr As XmlAttribute = doc.CreateAttribute("t", "attrName", "http://www.globuscosmos.com/") 'Inseriamo i child nel node node.AppendChild(details) node.AppendChild(details2) 'Eccezione Dim se As New SoapException("An Error Occured", _ SoapException.ClientFaultCode, _ Context.Request.Url.AbsolutePath, _ node) Throw se Return End Sub End Class
codice:... ... Try 'Esegue Something Catch ex as SoapException 'cosa metto?
Mi sa che ho sbagliato qualcosa perchè io non voglio intercettare le SoapException ma bensi' trasformare qualsiasi errore mi generi il webSerivces in una SoapException.
Qualcuno puo' aiutarmi?


Rispondi quotando