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

Discussion in 'ASP .Net' started by Spam Catcher, Jul 5, 2007.

  1. Spam Catcher

    Spam Catcher 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
     
    Spam Catcher, Jul 5, 2007
    #1
    1. Advertising

  2. RE: HELP!!! .NET 2.0 - Problem with Web Service Complex Types - 500 In

    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



    "Spam Catcher" wrote:

    > 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
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jul 5, 2007
    #2
    1. Advertising

  3. "Spam Catcher" <> wrote in message
    news:Xns9963E84F896A7usenethoneypotrogers@127.0.0.1...
    > 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.
    --
    John Saunders [MVP]
     
    John Saunders [MVP], Jul 5, 2007
    #3
  4. Spam Catcher

    Spam Catcher Guest

    "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in
    news::

    > 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 :-(
     
    Spam Catcher, Jul 6, 2007
    #4
  5. "Spam Catcher" <> wrote in message
    news:Xns99656BB9B264Fusenethoneypotrogers@127.0.0.1...
    > "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in
    > news::
    >
    >> 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 :-(


    I'm glad that worked for you. Simplifying the problem usually helps.
    --
    John Saunders [MVP]
     
    John Saunders [MVP], Jul 6, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Bonds
    Replies:
    2
    Views:
    2,795
    Amaryllis
    Aug 3, 2004
  2. Replies:
    5
    Views:
    80,650
    cpdarkman
    Aug 26, 2009
  3. BobbyOwens
    Replies:
    0
    Views:
    4,681
    BobbyOwens
    Jan 23, 2009
  4. JC
    Replies:
    0
    Views:
    182
  5. Replies:
    0
    Views:
    792
Loading...

Share This Page