Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing class Object to Web Service

Status
Not open for further replies.

phaseshift

IS-IT--Management
Dec 13, 2004
45
0
0
US
I have an ArrayList of objects that I need to pass to a web service.

The objects in the ArrayList are objects of a class that I created. When I pass the ArrayList to the Web Service I get an XML error " Cannot generate XML file". If I pass anything else to the Web Service it works just fine.

Any ideas?

Thanks
 
I believe you have to convert the arraylist to a regular array, and then pass it. Arraylist is made of objects, not a specific type so the xml decides to take a dump instead of write correctly.

try converting the arraylist to an array first.
 
I tried to convert my arraylist to an object[] and I get the same error;

What type of array should I use?
 
Try an array of that type (widget[], Foo[], etc).

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
whatever type of objects are actually in the ArrayList.

If you have an arraylist of yourCustomClass

yourCustomClass[] list = myArrayList.ToArray(typeof(yourCustomClass[]);
 
I got it. I had to inhert the class from the web service.

ws.MyCustomClass foo = new ws.MyCustomClass()

then when I was sending in the objects from the local app I had to cast my ArrayList to (ws.MyCustomClass).


Thanks a lot. Your comments got me thinking about his way.

 
I don't think that's correct. You should just need to inherit from MarshallByRefObject in order to make an object passable over a web service.

You're probably picking this class up through the inheritance tree, but that would also mean that you're also getting a lot of junk that you don't need.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top