tags:

views:

19

answers:

1

Hello,

I have description of my Application Services using my fancy classes (ServiceDescription class that contains collection of ServiceMethod description, for simplification).

Now, I want to expose one Application Service as one WCF Service (one Contract). The current solution is very lame - I have console application that generates *.svc file for each Application Service (ServiceDescription). There is one method (Operation) generated for one ServiceMethod.

This works well but I would like to make it better. It could be improved using T4 template but I'm sure that there is still better way in WCF.

I would still like to have one *.svc file per one Application Service but I don't want to generate methods (for corresponding Application Service methods). I'm sure that there must be some interfaces that allow to discover operations dynamically, at runtime. Maybe IContractBehavior...

Thanks.

EDIT1: I don't want to use generic operation contract because I would like to have the ability to generate service proxy with all operations.

I'm sure that if I write WCF service and operations by hand then WCF uses reflection to discover the operations in the service. Now, I would like to customize this point in order not to use reflection, just use my "operations discovering code" instead.

A: 

I think there is nothing wrong with static code generation in that case. In my opinion, it is a better solution than dynamic generation of contracts. Keep in mind that your contract is the only evidence you have/provide that a service is hosting a particular set operations.

The main issue I see about the dynamic approach is about versioning and compatibility. If everything is dynamically generated, you may end up transparently pushing breaking changes into the system and create some problems with existing clients.

If you have a code generator when you plan on implementing some changes in the application services, it will be easier to remember that the changes you make on the services may have a huge impact.

But if you really want to dynamically handle messages, you could use a generic operation contract (with the Action property set to *), and manually route the messages to the application services. Keep in mind that you would lose the ability to generate from the service a proxy containing a list of operations available.

Johann Blais
Thank you for your response. I'm working on intranet application, I'm handling both servers and clients, and I have integration tests that checks that both clients and servers to deploy are up to date. So I hope that dynamic approach is ok in my case. I don't want to use generic operation contract because I would like to have the ability to generate service proxy with all operation. I'm sure that if I write WCF service and operations by hand then WCF uses reflection to discover the operations in the service. Now, I would like to customize this point in order not to use reflection.
Augi