views:

73

answers:

2

Hi I was asked this question - How do you start consuming a WCF service in advance (read before being implemented/deployed)?

I couldn't think of a very convincing answer and said probably we can generate a proxy and provide some stubs ..etc... you got the idea. Even I was not convinced with myself. The question do make sense as presentation and services are different tiers. One should not be waiting on other in development at least.

Anyways, so I have been thinking since then and need some pointers on this from experts out there. Any suggestions / aproaches?.

Thanks

AJ

+1  A: 

Well, if you have the contracts and all, you could always create your own mock implementation of the service.

E.g. create your own "MockFinancialDataService" from your service and data contracts, and then just add a totally simple implementation, e.g. returning some fixed values or something.

Host those mock services in your environment - in IIS or self-hsoting - and program against those.

Shouldn't be too hard, really.

There's also a toolset called Mockingbird on Codeplex which promises to ease that "mock implementation" story a bit - haven't had time to fully investigate it yet, but maybe you want to have a look at it anyway.

marc_s
All good suggestions guys. Thanks. MockingBird tool sounds promising. Will give it a try.
AJ
+2  A: 

It depends in part on how your are configuring WCF; one option is to use assembly sharing (rather than mex-generated proxies) - in which case you already have your service contract: it is just the interface (and DTO classes) in the paired dll. From this you can mock away to your hearts content, and changing to the real service is simply a case of configuring your app.config/web.config and switching your IoC/DI layer to use WCF (not hard, but "how" depends on your choice of IoC/DI).

Marc Gravell