Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Serializing custom business objects

Reply
Thread Tools

Serializing custom business objects

 
 
Michael_vb
Guest
Posts: n/a
 
      11-13-2006
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

 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      11-14-2006
"Michael_vb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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


 
Reply With Quote
 
 
 
 
Michael_vb
Guest
Posts: n/a
 
      11-14-2006
No this is a .net to .net application
John Saunders wrote:
> "Michael_vb" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > 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


 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      11-14-2006
"Michael_vb" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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


 
Reply With Quote
 
kferron
Guest
Posts: n/a
 
      11-15-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serializing objects that are only available through a factory Hendrik Maryns Java 2 12-02-2008 02:24 PM
Serializing objects into a stream blazingdragon@gmail.com Java 3 04-06-2006 11:14 AM
Problem in serializing objects in session sangha Java 4 03-08-2006 09:45 PM
Serializing generic objects Christopher V. Kimball Java 0 12-11-2004 11:06 PM
Re: template and static WAS: Re: serializing/unserializing objects... john smith C++ 0 08-09-2003 09:58 AM



Advertisments