views:

368

answers:

2

Hi,

If for example, you have customers, orders and products. Do you create a separate service for each of these business entities?

It kinda feels logical that you should create a service contract for each of these. However, since you have to explicitly specify the contract that your service will implement… this sort of forces you to create a separate service for each service contract, does it not?

Could you please tell me how you would handle this? Somehow it feels ungainly to have a service for ever business entity… :-(

In advance, many thanks and regards.

+3  A: 

Services act on business entities, but are not business entities.

So customers, orders and products would be data contracts, not service contracts.

It's the actions you perform on those data contracts that form your service contract, and the actions you expose on an entity may or not be all the things that entity can do.

If, as I think you might be asking, each entity has common functionality (CRUD operations for example) then yes, you should have a separate service contact for a CRUD service on each entity (CustomerCRUDService, OrderCRUDService etc.) because web services don't support overloads on method signatures.

(From the comments)

There are a couple of ways.

1) Composite service contracts: For example I have a service that implements WSTransfer - this actually is comprised of two service contracts, IWSTransferResource and IWSTransferFactory. In turn I have an IWSTransfer service contract that just implements those separate contracts - public interface IWSTransfer : IWSTransferResource, IWSTransferFactory

2) But you don't even have to get that complicated, an implementation in WCF can implement multiple service contracts - MyServiceImpl : IMyContract1, IMyContract2. However each contract needs a separate endpoint, because endpoints are for service contracts, not implementation classes.

blowdart
Hi blowdart,I should have been clearer. My question is: For every ServiceContract, must you have a separate service?Thanks for your response.
You have confirmed what I had hoped was not the case :-)Thanks again!
A: 

Hi Ryan,

I'm at the point where I was asking the same questions when I came across your post. Could I ask how you went about structuring your project?

Thanks in advance,

Al.

John Saunders