N
Nick Locke
I am trying to encapsulate logic within classes, so I have this:
Public Class StolenVehicleTemplate
Private _Make As String
Public Property Make() As String
Get
Make = _Make
End Get
Set(ByVal value As String)
If value = "" Then
ThrowException("E701", "Make cannot be blank")
End If
_Make = value
End Set
End Property
Private Sub ThrowException(ByVal strCode As String, ByVal strMessage As
String)
Dim node As System.Xml.XmlNode =
doc.CreateNode(System.Xml.XmlNodeType.Element, _
SoapException.DetailElementName.Name, _
SoapException.DetailElementName.Namespace)
' Node gets built here
Dim objException As New SoapException("One or more mandatory
elements was not specified", _
SoapException.ClientFaultCode, _
"", _
node)
Throw objException
End Sub
End Class
Whatever I try, I cannot persuade the detail element (node) to appear in the
exception. When I use exactly the same code, but directly within a
webmethod rather than in a class that is referenced from the webmethod, it
all works fine.
Am I missing something? I really want to be able to give the consumer a bit
more detail, without having to define it again and again, every time I use
the class.
Public Class StolenVehicleTemplate
Private _Make As String
Public Property Make() As String
Get
Make = _Make
End Get
Set(ByVal value As String)
If value = "" Then
ThrowException("E701", "Make cannot be blank")
End If
_Make = value
End Set
End Property
Private Sub ThrowException(ByVal strCode As String, ByVal strMessage As
String)
Dim node As System.Xml.XmlNode =
doc.CreateNode(System.Xml.XmlNodeType.Element, _
SoapException.DetailElementName.Name, _
SoapException.DetailElementName.Namespace)
' Node gets built here
Dim objException As New SoapException("One or more mandatory
elements was not specified", _
SoapException.ClientFaultCode, _
"", _
node)
Throw objException
End Sub
End Class
Whatever I try, I cannot persuade the detail element (node) to appear in the
exception. When I use exactly the same code, but directly within a
webmethod rather than in a class that is referenced from the webmethod, it
all works fine.
Am I missing something? I really want to be able to give the consumer a bit
more detail, without having to define it again and again, every time I use
the class.