For Programmers: Free Programming Magazines  


Home > Archive > C# > December 2005 > serialize object









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author serialize object
kumki

2005-12-03, 3:58 am

Hi,


In my windows application i need to pass an arraylist to a webservice that would accept this arraylist as a "serialized object".

So in the method that calls the webservice i have type casted the arraylist to an object but the problem here is i have no idea as to how to serialize this object and pass this serialized object to a webservice...

Waiting for ur reply,

kumki
spalding

2005-12-19, 9:06 pm

Hi

Okay, I'm going to make some assumptions here but hopefully it'll answer your question (if my assumptions are wrong, feel free to rebutt);

1. You are returning an ArrayList of complex datatypes, most likely an object you have defined yourself,

2. You return this arraylist via a method which you expose via a web service.

Okay, the first problem is an ArrayList is too complex to be transmitted via a web service, so what you have to do is recast it for xml/soap.

Lets assume you have an arraylist of User objects which you wish to return from a method named GetUserList().
You will need to use;

[XmlInclude(typeof(User[]))]
public ArrayList GetUserList()
{
....
}

to recast down to something more understandable to SOAP, that is, a simple array of objects.

Hope this helps.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com