Using ReadOnlyCollection exposed as a webservice from client

Using ReadOnlyCollection exposed as a webservice from client

Old forum URL: forums.lhotka.net/forums/t/6196.aspx


DazedAndConfused posted on Monday, January 19, 2009

If I am returning a read only collection

public class MyReadOnlyCollection : ReadOnlyListBase<MyReadOnlyCollection, MyReadOnly>

via a method in a web service, and what to access and use the collection, is it possible?

This is my web service method:

[OperationContract]

public MyReadOnlyCollection MyCollectyion()

When I add a web reference, it cannot seem to see the collection , but returns the readonly object as a reference that I can use. Ideally I want to loop around the Read Only collection and access each read only object on the client.

 

 

 

RockfordLhotka replied on Monday, January 19, 2009

It is not possible to return a CSLA business object directly as the result of a web service.

It is also not desirable to do this. It is just a bad idea, and so I have never tried to make it work. No sense enabling something no one should ever do :)

There are numerous threads on this topic in the forum. But there's also a complete chapter in the Expert Business Objects book (chapter 11 in 2005 and chapter 21 in 2008) that discusses the issues and solutions around XML service interfaces.

DazedAndConfused replied on Monday, January 19, 2009

Thanks Rocky, I took a look at the chapter, so you would advice wrapping the csla business objects with a new abstraction class layer, will look to do this instead. This is what I have done previously, but wondered if there was an easier (less time consuming) method.

Thanks.

Copyright (c) Marimer LLC