Serializing custom business objects

Discussion in 'ASP .Net Web Services' started by Michael_vb, Nov 13, 2006.

  1. Michael_vb

    Michael_vb Guest

    It seems if i have a custom business object that inherits from an
    arraylist, it will not serialize it correctly on the proxy side.Well my
    issue is that i have a business object that has a member of
    phonenumbers which inherits from arraylist. The reason is because i
    could have more than one phone number. How can i get around this issue
    on the proxy side, here is my code

    Web service code
    <WebMethod()> Public Function SaveCase(ByVal Myrequest As CaseRequest)


    End Function
    End Class

    <System.Serializable()> Public Class CaseRequest
    Public FirstName As String
    Public LastName As String
    Private _phone As PhoneNumbers

    Public Property Phone() As PhoneNumbers
    Get
    Return _phone
    End Get
    Set(ByVal value As PhoneNumbers)
    _phone = value
    End Set
    End Property

    End Class

    <System.Serializable()> Public Class PhoneNumbers
    inherits arraylist
    Public Type As String
    Public Number As String
    Public Sub New()
    End Sub
    End Class


    On the client side there is no Phonenumbers class created,also the
    member phone from the caserequest class is not an arraylist. Any
    ideas!!

    asp.net web service 2.0
     
    Michael_vb, Nov 13, 2006
    #1
    1. Advertising

  2. "Michael_vb" <> wrote in message
    news:...
    > It seems if i have a custom business object that inherits from an
    > arraylist, it will not serialize it correctly on the proxy side.Well my
    > issue is that i have a business object that has a member of
    > phonenumbers which inherits from arraylist. The reason is because i
    > could have more than one phone number. How can i get around this issue
    > on the proxy side, here is my code


    ArrayList is a platform-specific type. You should not use platform-specific
    types in a web service. What do you expect a Java client to do with your
    ArrayList, for example?

    John
     
    John Saunders, Nov 14, 2006
    #2
    1. Advertising

  3. Michael_vb

    Michael_vb Guest

    No this is a .net to .net application
    John Saunders wrote:
    > "Michael_vb" <> wrote in message
    > news:...
    > > It seems if i have a custom business object that inherits from an
    > > arraylist, it will not serialize it correctly on the proxy side.Well my
    > > issue is that i have a business object that has a member of
    > > phonenumbers which inherits from arraylist. The reason is because i
    > > could have more than one phone number. How can i get around this issue
    > > on the proxy side, here is my code

    >
    > ArrayList is a platform-specific type. You should not use platform-specific
    > types in a web service. What do you expect a Java client to do with your
    > ArrayList, for example?
    >
    > John
     
    Michael_vb, Nov 14, 2006
    #3
  4. "Michael_vb" <> wrote in message
    news:...
    > No this is a .net to .net application


    But you're using Web Services, which is a platform-independent paradigm. You
    are therefore subject to its limitations. Among other things the
    ..NET-specific details of your type are not communicated between client and
    server.

    I would suggest returning an array instead of an arraylist. If the client
    then decides to further manipulate the data using an ArrayList, it is free
    to do so.

    If you require type-fidelity, you should consider using .NET Remoting,
    despite the predictions of its demise.

    John
     
    John Saunders, Nov 14, 2006
    #4
  5. Michael_vb

    kferron Guest

    Michael, this is a little off topic of your direct question, but you
    should first of all consider not using a derived class of ArrayList for
    *any* of your collections. Consider instead that if you have a
    PhoneNumber type that is serializable, using a generic collection that
    you can attribute serialization rules to would be ideal in your
    situation. The client will still have to know how to hydrate the
    appropiate types on their end.

    ~kcf
     
    kferron, Nov 15, 2006
    #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. Stylus Studio
    Replies:
    0
    Views:
    406
    Stylus Studio
    Feb 17, 2006
  2. GOOD LUCK GROUP
    Replies:
    0
    Views:
    405
    GOOD LUCK GROUP
    Apr 28, 2008
  3. Dan Caron
    Replies:
    1
    Views:
    191
  4. Mohammed Imran
    Replies:
    0
    Views:
    316
    Mohammed Imran
    Mar 25, 2013
  5. Mohammed Imran
    Replies:
    1
    Views:
    509
Loading...

Share This Page