tags:

views:

255

answers:

2

I have a webservice that is designed to accept performance data via a custom object. The custom object contains a Collection (Generic List) of performance measures among other data. The performance measure consists of simple data types (strings, ints, and a datetime). The only method exposed by the webservice requires this custom object (performance data object) to be passed in.

The problem lies in using this custom object externally. I wish to use the Add() and Item() methods of the Generic List class along with various other features within this class within another webservice. If I request the object from the Performance Data Webservice it seralizes the inner collection to an arrayList. I would like it to remain a generic collection.

I have toyed with using the XmlInclude method but currently havent found a solution with it.

The next thing I tried to do was create an assembly of this specific object that both the Peformance Data web service can use and any satelite programs (i.e. another webservice). The issue here is when I try to pass in the custom object created by the seperate assembly the performance data webservice barks its a different type. (Also I am applying the XmlInclude(GetType( custom assembly)) attribute to the exposed method). However still thinks the types are not convertable.

Note: I would prefer to call the Performance Data WS to get the custom object instead of having to deal with adding assemblies to each project that needs access.

Anyone have an idea other than restructing the program to work with methods exposed by the ArrayList?

A: 

If you use WCF, you can configure what type of collection comes out, whether an ArrayList, a fixed array, or a generic List.

Rap
I am using .Net 2.0 unfortunately.
ZD
You should stop doing that. There's no good reason for it. At least update to .NET 2.0 SP2.
John Saunders
I am using 2.0 SP2.WCF is a 3.x foundation.
ZD
A: 

I have found a solution that will work with .Net 2.0. By using Web Services Contract First (WSCF http://www.thinktecture.com/resourcearchive/tools-and-software/wscf/wscf-walkthrough) I was able to pass generic collections between two services. A down side to WSCF, as the name suggests, is the approach requires the use of contract-first instead of the more common code-first methodology. Lucky it is not terribly complicated to modify the class and proxy after they are created. Hope this helps any lost travelers...

ZD
It's not a best practice to modify generated code, since your modifications will be lost as soon as the code is generated again.
John Saunders
I agree this is not a best practice. Once the code is generated the first time, I do not use the auto generate again. I simply modify the proxy class just as i would any other class. The coding is the same with the exception of xml tags being applied to the methods. Please provide a better idea if you have one.
ZD