TK101
TK101

Reputation: 41

.NET SOAP and complex data types

Are there any issues in using List or any other complex data types with .NET SOAP web service? Is it best practice to use an array?

Upvotes: 1

Views: 518

Answers (3)

dana
dana

Reputation: 18105

WebServices can serialize a lot, I have even seen them return DataTables (not recommended). However, I have found it cleaner to use Data Transfer Objects (DTO) when returning complex types. These objects are created for your web service only and gives you more control over what your service returns.

If I need to return a list of items, I will use a plain old array vs an IList. The generated WSDLs seem to be a lot cleaner this way.

Upvotes: 1

dice
dice

Reputation: 2880

It does not matter wether you use an array or a list, they are converted to SOAP as a repeating element.

FYI a client using WCF can chose to deserialize it as an array or a list.

Upvotes: 2

Nico Schertler
Nico Schertler

Reputation: 32587

Lists, arrays and other collections are converted into a soap-specific collection. So in the end, there is no difference in most cases.

Upvotes: 2

Related Questions