Soap Fault from within a class - no Detail

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.
 
J

John Saunders

Nick Locke said:
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.


What happens when you use a non-blank actor parameter?

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top