Reputation: 19507
My application communicates with a large number of wcf services i.e. my application has several assemblies which each consume a different wcf service.
I am looking for a good wcf client design pattern so that I can keep my code concise, reusuable and elegant.
The wcf services which I consume are all the same - the basically used to check prices and then book things.
Upvotes: 5
Views: 2276
Reputation: 233125
When you say the all services are the same, I presume that you mean that they are similar.
If they are truly identical, you should be able to use the same WCF client for all of them (just with different addresses).
If this is not the case, you can define an interface that conforms the exposed functionality. This might look like:
public interface IMyService
{
decimal GetPrice(int productId);
void Book(int thingId);
}
Now write implementations of IMyService that serves as Adapters between each WCF client and IMyService.
In the rest of your application, you only program against the IMyService interface. Optionally, you can use Dependency Injection to inject either one or many concrete IMyService implementations into the application code.
Upvotes: 4