I want to create an asmx webservice that would return a list of companies for example but that will be consume开发者_StackOverflow社区d by non .net clients so what return type should I use ?
Every 1-dimensional XML-serializable collection type will be serialized to an xs:sequence
in the WSDL, so it doesn't really matter which type you use. List<T>
and T[]
(array) are the two most common.
If you really want interop, though, you'd be wise to stay away from legacy ASMX and use WCF instead. It's much easier to create POX or JSON services/methods using WCF, and those protocols/formats are more widely accessible than SOAP.
What about serializing your work objects and returning them directly as plain XML or JSON? In that case, it pretty much doesn't matter what object type you use, since the defined format is not tied to a specific language/framework.
精彩评论