ReadOnlyListBase and Webservices

ReadOnlyListBase and Webservices

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


ataylorm posted on Wednesday, November 28, 2007

We are in the design stages of an application which requires an open API which can be accessed by developers in Mobile, Desktop, etc.  These may be running windows, mac os x, linux, etc.  This API needs to be consumable as a web service.  Since we are a bit new at this end of things, does anyone know if and how we would return say a ReadOnlyListBase object through the webservice that can be consumed by anyone?  Is that even possible, or do we need to send out an XML string or something instead?

Thanks!

Andrew

RockfordLhotka replied on Wednesday, November 28, 2007

I suggest reading Chapter 11 of the Expert Business Objects book, as I cover this exact scenario.

The short answer is that you shouldn't return a business object from a service. Instead, you should create a contract-based DTO (data transfer object) that you return from the service. The code for the service then is typically pretty simple: retrieve the business object, copy its data into the DTO and return the DTO.

ataylorm replied on Thursday, November 29, 2007

Thank you, we haven't managed to get that deep into the book yet. :)

-------- Original Message --------
Subject: Re: [CSLA .NET] ReadOnlyListBase and Webservices
From: "RockfordLhotka" <cslanet@lhotka.net>
Date: Wed, November 28, 2007 6:54 pm
To: "andrew@project-unicorn.com" <andrew@project-unicorn.com>

I suggest reading Chapter 11 of the Expert Business Objects book, as I cover this exact scenario.
The short answer is that you shouldn't return a business object from a service. Instead, you should create a contract-based DTO (data transfer object) that you return from the service. The code for the service then is typically pretty simple: retrieve the business object, copy its data into the DTO and return the DTO.



Copyright (c) Marimer LLC