Geeks With Blogs
Prasanna's Blog BizTalk, WCF, C# and Software Factories

Few weeks ago i was training our offshore team on WCF and WSSF. while the guys were doing hands on, they had noticed that the Generic List what they were returning from WCF service was converted to Array and they had no clue why it was happening.

Answer :

Because web services / WCF Service are platform-agnostic, they need to use the most primitive data types. 

Scenerio 1 :

 what would happen if your web service would be consumed by a .NET 1.x application, where no generics are available.

Scenerio 2 :

How would non .Net applications (J2ee or PHP) will consume the service, which doenst have the knowledge of .Net Generics?

The convertion happens because array is the lowest common denominator.

Is that means that we shouldn't be using generic List<T> in the service, the answer is yes you should :-), Because the Native .net applications can take advantage of the Generic List<T> like windows form application in .Net version 2.0 and above

Note : The webservice / WCF service proxy's are generated on the fly based on the nature of the client your using with. if you use them with Windows Form application you will still see the proxy generated will be with the List objects. where us if you use it in application the same interface will be generated with Array.

Happy Programming !!!

Posted on Friday, January 25, 2008 1:02 AM | Back to top

Comments on this post: .Net Generic List gets converted to Array when exposed to the WCF client

# re: .Net Generic List gets converted to Array when exposed to the WCF client
Requesting Gravatar...
thank you this was helpful to me
Left by Simon Cooper on Apr 12, 2010 10:47 AM

Your comment:
 (will show your gravatar)

Copyright © Prasanna Krishnan | Powered by: