Return collection of data contract type

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
Jun 11, 2009 at 6:19 PM
Hi, I'm just starting with the Web Service Software Factory and am trying to model a very simple scenario where an operation takes no parameters and returns a collection of a type defined in a data contract. In other words, it's going to be called something like this: IEnumerable<Product> allProducts = client.GetAllProducts(); I have two questions: 1) Should I model a request message (presumably with no parts) or should I leave that step out? 2) How do I model the return type? Collections only appear to be available for primitive types. I'm sure I'm missing something really simple, because this must be a very common scenario. However, I'd be grateful if someone would take pity on my obvious stupidity and let me know how it's done. Many thanks, Peter
Jun 11, 2009 at 7:23 PM

I would model as the following:

Operation: GetAllProducts() which would have a single message contract called GetAllProductsResponse. Do not need a Request message Contract.

GetAllProductsResponse would contain a Part call Products which would be of type Data Contract Collection "Products" (Need to define this first)

In Data Contract Model 1) define a Data Contract called Product, this is where you will add Members about the product. 2) Define a Data Contract Collection called Products.

In the Properties window for Products set Data Contract property value to Product. (You have now defined a collection of products).

Jun 11, 2009 at 7:42 PM
Aaaah! The light just went on :0)

First the request message. Thanks for that. I'd actually done that,
but just needed re-assurance I think.

Now the collection. OK, I'm an idiot. I'd been so blinded by following
the instructions I wrote for myself about adding data contracts by
dragging a Data Contract onto the design surface, that I never noticed
the Data Contract Collection tool in the Toolbox.

Apologies for time wasting, but a million thanks both for giving me the
answer and for not pointing out my obvious lack of observation skills.

Thanks a lot


Peter


mmilchuk wrote:
>
> From: mmilchuk
>
> I would model as the following:
>
> Operation: GetAllProducts() which would have a single message contract
> called GetAllProductsResponse. Do not need a Request message Contract.
>
> GetAllProductsResponse would contain a Part call Products which would
> be of type Data Contract Collection "Products" (Need to define this first)
>
> In Data Contract Model 1) define a Data Contract called Product, this
> is where you will add Members about the product. 2) Define a Data
> Contract Collection called Products.
>
> In the Properties window for Products set Data Contract property value
> to Product. (You have now defined a collection of products).
>
> Read the full discussion online
> <http://servicefactory.codeplex.com/Thread/View.aspx?ThreadId=59223&ANCHOR#Post200538>.
>
> To add a post to this discussion, reply to this email
> ([email removed]
> <mailto:[email removed]?subject=%5Bservicefactory:59223%5D>)
>
> To start a new discussion for this project, email
> [email removed]
> <mailto:[email removed]>
>
> You are receiving this email because you subscribed to this discussion
> on CodePlex. You can unsubscribe or change your settings
> <http://www.codeplex.com/site/discussions/project/unsubscribe/servicefactory>
> on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any
> posts to this discussion will also be available online at codeplex.com
>