HELP!!! .NET 2.0 - Problem with Web Service Complex Types - 500 Internal Server Error? Framework Bug

G

Guest

Hello,

I am developing a web service with the following signature:

Public Function MyFunction(ByVal Contact as ContactDTO) as ContactDTO

When I add this function into my project, I get a 500 Internal Server Error
when I try to access the web service. I believe this is a framework bug?

If I remove the function or remove the parameter, my project works OK.
ContactDTO is a object which is used to transfer data, a couple other
functions use this object but only to return data (not as an input
parameter) and they work OK.

I've seem to have isolated the problem down to two parameters within my
ContactDTO class:

Public Property ContactDestinations() As ContactDestinationDTO()
Get
Return mContactDestination.ToArray
End Get
Private Set(ByVal value As ContactDestinationDTO())

End Set
End Property

Public Property ContactEventDestinations() As
ContactEventDestinationDTO()
Get
Return mContactEventDestination.ToArray
End Get
Private Set(ByVal value As ContactEventDestinationDTO())

End Set
End Property


If I comment out these properties, my code seems to work OK.

So my question is:

1. Why is my web service throwing a 500 Internal Service Error? This seems
to be a framework bug?

2. The ContactDTO works OK as a return parameter, but not as an input
parameter?

3. Why is my web service having problems accepting an object with the two
properties above?




Here is my code:


Public Class ContactDTO
Private mContactID As Nullable(Of Integer)
Private mFirstName As String
Private mLastName As String
Private mLanguageID As Integer
Private mUserID As Nullable(Of Integer)
Private mClient As ClientDTO
Private mDisabled As Boolean
Private mDeleted As Boolean
Private mContactDestination As New List(Of ContactDestinationDTO)
Private mContactEventDestination As New List(Of
ContactEventDestinationDTO)

Public Sub New()

End Sub

Public Sub New(ByVal Contact As ContactEntity)
With Contact
mContactID = .ContactId
mFirstName = .FirstName
mLastName = .LastName
mLanguageID = .LanguageId
mUserID = .UserId
mClient = New ClientDTO(.Client)
mDisabled = .Disabled
mDeleted = .Deleted

For Each ContactDestination As ContactDestinationEntity In
..ContactDestinations
mContactDestination.Add(New ContactDestinationDTO
(ContactDestination))
Next

For Each ContactEventDestination As
ContactEventDestinationEntity In .ContactEventDestinations
mContactEventDestination.Add(New ContactEventDestinationDTO
(ContactEventDestination))
Next
End With
End Sub

Public Property ContactID() As Nullable(Of Integer)
Get
Return mContactID
End Get
Set(ByVal value As Nullable(Of Integer))
mContactID = value
End Set
End Property

Public Property FirstName() As String
Get
Return mFirstName
End Get
Set(ByVal value As String)
mFirstName = value
End Set
End Property

Public Property LastName() As String
Get
Return mLastName
End Get
Set(ByVal value As String)
mLastName = value
End Set
End Property

Public Property LanguageID() As Integer
Get
Return mLanguageID
End Get
Set(ByVal value As Integer)
mLanguageID = value
End Set
End Property

Public Property UserID() As Nullable(Of Integer)
Get
Return mUserID
End Get
Set(ByVal value As Nullable(Of Integer))
mUserID = value
End Set
End Property

Public Property Client() As ClientDTO
Get
Return mClient
End Get
Set(ByVal value As ClientDTO)
mClient = value
End Set
End Property

Public Property Disabled() As Boolean
Get
Return mDisabled
End Get
Set(ByVal value As Boolean)
mDisabled = value
End Set
End Property

Public Property Deleted() As Boolean
Get
Return mDeleted
End Get
Set(ByVal value As Boolean)
mDeleted = value
End Set
End Property

Public Property ContactDestinations() As ContactDestinationDTO()
Get
Return mContactDestination.ToArray
End Get
Private Set(ByVal value As ContactDestinationDTO())

End Set
End Property

Public Property ContactEventDestinations() As
ContactEventDestinationDTO()
Get
Return mContactEventDestination.ToArray
End Get
Private Set(ByVal value As ContactEventDestinationDTO())

End Set
End Property
End Class


Public Class ContactDestinationDTO

Private mContactID As Nullable(Of Integer)
Private mDestinationType As DestinationTypeDTO = Nothing
Private mValue As String
Private mNotificationOrder As Integer
Private mTimeZone As TimeZoneDTO
Private mDisabled As Boolean
Private mContactDestinationSchedules As New List(Of
ContactDestinationScheduleDTO)

Public Sub New()

End Sub

Public Sub New(ByVal ContactDestination As ContactDestinationEntity)
With ContactDestination
mContactID = .ContactId
mDestinationType = New DestinationTypeDTO(.DestinationType)
mValue = .Value
mNotificationOrder = .NotificationOrder
mTimeZone = New TimeZoneDTO(.TimeZone)
mDisabled = .Disabled

For Each Schedule As ContactDestinationScheduleEntity In
ContactDestination.ContactDestinationSchedules
mContactDestinationSchedules.Add(New
ContactDestinationScheduleDTO(Schedule))
Next
End With
End Sub

Public Property ContactID() As Nullable(Of Integer)
Get
Return mContactID
End Get
Set(ByVal value As Nullable(Of Integer))
mContactID = value
End Set
End Property

Public Property DestinationType() As DestinationTypeDTO
Get
Return mDestinationType
End Get
Set(ByVal value As DestinationTypeDTO)
mDestinationType = value
End Set
End Property

Public Property Value() As String
Get
Return mValue
End Get
Set(ByVal value As String)
mValue = value
End Set
End Property

Public Property NotificationOrder() As Integer
Get
Return mNotificationOrder
End Get
Set(ByVal value As Integer)
mNotificationOrder = value
End Set
End Property

Public Property TimeZone() As TimeZoneDTO
Get
Return mTimeZone
End Get
Set(ByVal value As TimeZoneDTO)
mTimeZone = value
End Set
End Property

Public Property Disabled() As Boolean
Get
Return mDisabled
End Get
Set(ByVal value As Boolean)
mDisabled = value
End Set
End Property

Public Property ContactDestinationSchedules() As
ContactDestinationScheduleDTO()
Get
Return mContactDestinationSchedules.ToArray()
End Get
Private Set(ByVal value As ContactDestinationScheduleDTO())
mContactDestinationSchedules.Clear()
mContactDestinationSchedules.AddRange(value)
End Set
End Property
End Class


Public Class ContactDestinationScheduleDTO
Private mContactDestinationScheduleID As Nullable(Of Integer)
Private mContactID As Nullable(Of Integer)
Private mDestinationType As DestinationTypeDTO
Private mContactGroupID As Nullable(Of Integer)
Private mEventID As Nullable(Of Integer)
Private mDayOfWeekID As Integer
Private mStartTime As DateTime
Private mEndTime As DateTime
Private mTimeZone As TimeZoneDTO
Private mDaylightSavingsEnabled As Boolean

Public Sub New()

End Sub

Public Sub New(ByVal ContactDestinationSchedule As
ContactDestinationScheduleEntity)
With ContactDestinationSchedule
mContactDestinationScheduleID = .ContactDestinationScheduleId
mContactID = .ContactId
'mDestinationType = New DestinationTypeDTO(.DestinationType)
mContactGroupID = .ContactGroupId
mEventID = .EventId
mDayOfWeekID = .DayOfWeekId
mStartTime = .StartTime
mEndTime = .EndTime
mTimeZone = New TimeZoneDTO(.TimeZone)
mDaylightSavingsEnabled = .DaylightSavingsEnabled
End With
End Sub

Public Property ContactDestinationScheduleID() As Nullable(Of Integer)
Get
Return mContactDestinationScheduleID
End Get
Set(ByVal value As Nullable(Of Integer))
mContactDestinationScheduleID = value
End Set
End Property

Public Property ContactID() As Nullable(Of Integer)
Get
Return mContactID
End Get
Set(ByVal value As Nullable(Of Integer))
mContactID = value
End Set
End Property

Public Property DestinationType() As DestinationTypeDTO
Get
Return mDestinationType
End Get
Set(ByVal value As DestinationTypeDTO)
mDestinationType = value
End Set
End Property

Public Property ContactGroupID() As Nullable(Of Integer)
Get
Return mContactGroupID
End Get
Set(ByVal value As Nullable(Of Integer))
mContactGroupID = value
End Set
End Property

Public Property EventID() As Nullable(Of Integer)
Get
Return mEventID
End Get
Set(ByVal value As Nullable(Of Integer))
mEventID = value
End Set
End Property

Public Property DayOfWeekID() As Integer
Get
Return mDayOfWeekID
End Get
Set(ByVal value As Integer)
mDayOfWeekID = value
End Set
End Property

Public Property StartTime() As DateTime
Get
Return mStartTime
End Get
Set(ByVal value As DateTime)
mStartTime = value
End Set
End Property

Public Property EndTime() As DateTime
Get
Return mEndTime
End Get
Set(ByVal value As DateTime)
mEndTime = value
End Set
End Property

Public Property TimeZone() As TimeZoneDTO
Get
Return mTimeZone
End Get
Set(ByVal value As TimeZoneDTO)
mTimeZone = value
End Set
End Property

Public Property DaylightSavingsEnabled() As Boolean
Get
Return mDaylightSavingsEnabled
End Get
Set(ByVal value As Boolean)
mDaylightSavingsEnabled = value
End Set
End Property
End Class

Public Class ContactEventDestinationDTO
Private mContactID As Integer
Private mEventID As Integer
Private mDestinationTypeID As Integer
Private mIgnoreSchedules As Boolean
Private mDisabled As Boolean

Public Sub New()

End Sub

Public Sub New(ByVal ContactEventDestination As
ContactEventDestinationEntity)
With ContactEventDestination
mContactID = .ContactId
mEventID = .EventId
mDestinationTypeID = .DestinationTypeId
mIgnoreSchedules = .IgnoreSchedules
mDisabled = .Disabled
End With
End Sub

Public Property ContactID() As Integer
Get
Return mContactID
End Get
Set(ByVal value As Integer)
mContactID = value
End Set
End Property

Public Property EventID() As Integer
Get
Return mEventID
End Get
Set(ByVal value As Integer)
mEventID = value
End Set
End Property

Public Property DestinationTypeID() As Integer
Get
Return mDestinationTypeID
End Get
Set(ByVal value As Integer)
mDestinationTypeID = value
End Set
End Property

Public Property IgnoreSchedules() As Boolean
Get
Return mIgnoreSchedules
End Get
Set(ByVal value As Boolean)
mIgnoreSchedules = value
End Set
End Property

Public Property Disabled() As Boolean
Get
Return mDisabled
End Get
Set(ByVal value As Boolean)
mDisabled = value
End Set
End Property
End Class
 
G

Guest

Spam Catcher,
I doubt very much that your issue is a .NET Framework "bug". Rather than
tediously poring over all the code you've posted, I have this suggestion:

In debug mode, put a breakpoint on the call to the webservice. If it doesn't
"debug through" to the actual webservice asmx page, run the webservice so
that the discovery page (Service description) is showing in your browser,
and have a Debugger.break statement in the beginning of the method. You can
also put try / catch statement around the method body and output any
exception message and StackTrace to the debug output window so you can
examine what went wrong.

--Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com
 
J

John Saunders [MVP]

Spam Catcher said:
Hello,

I am developing a web service with the following signature:

Public Function MyFunction(ByVal Contact as ContactDTO) as ContactDTO

When I add this function into my project, I get a 500 Internal Server
Error
when I try to access the web service. I believe this is a framework bug?

Internal Server Error usually means that there is an unhandled exception in
the web service. Take a look in the system event log.

I suspect that part of your problem is that your ContactDTO has no public
members. Change your fields from Private to Public and see what happens.

If that doesn't work, try changing the type from ContactDTO to String and
see if that gets the 500 error.
 
G

Guest

I suspect that part of your problem is that your ContactDTO has no
public members. Change your fields from Private to Public and see what
happens.

If that doesn't work, try changing the type from ContactDTO to String
and see if that gets the 500 error.

Yes, that turned out to be exactly the problem.

Strangely, ContactDTO could have no public write property for return
objects, but as an input object it must have both read/write properties. I
guess this makes sense since the framework needs to serialize the object
for input into the WS.

The Framework/ASP.NET didn't throw an error messages because WSE was
loaded. WSE was intercepting all messages prior thus preventing my debugger
from working. It was driving me nuts! I had to strip out all WSE related
code before I could get any meaningful error messages to show up :-(
 
J

John Saunders [MVP]

Spam Catcher said:
Yes, that turned out to be exactly the problem.

Strangely, ContactDTO could have no public write property for return
objects, but as an input object it must have both read/write properties. I
guess this makes sense since the framework needs to serialize the object
for input into the WS.

The Framework/ASP.NET didn't throw an error messages because WSE was
loaded. WSE was intercepting all messages prior thus preventing my
debugger
from working. It was driving me nuts! I had to strip out all WSE related
code before I could get any meaningful error messages to show up :-(

I'm glad that worked for you. Simplifying the problem usually helps.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top