I would make a shell that matches the web service interface. It would also be nice to wrap all exposed objects. Basically create a proxy. What I find very useful for this type of thing is to create an interface that matches the API and implement it. This way you can create a dummy version of the DLL for testing without the overhead (or potential overhead) associated with calling WCF. It will also make it easier if you need to replace the WCF call with an alternative provider in the future.
As an example, suppose we have a WCF service for an external provider to process a payment. Something like that:
void ProcessPayment(float amount);
We could easily connect this to our code. The problem is that simply changing the interface will result in us having to make changes to everything that the code refers to. The same would be necessary if we changed providers to someone else, even if the interface was almost identical. Adding something like a simple interface:
interface IPaymentProvider { void ProcessPayment(float amount); }
Completely disconnect our code from the WCF service. We could easily create a class like this:
class PaymentProviderAWrapper : IPaymentProvider { void ProcessPayment() {
What we could dynamically load with a factory infrastructure or dependent injection like Spring.NET. Going to provider B will be as easy as creating a new shell:
class PaymentProviderBWrapper : IPaymentProvider { void ProcessPayment() {
Switching your code from provider A to B will be as simple as changing the configuration settings.
Even if we compiled the library directly into our code, all we need to do is change the design logic to use the new library. The rest of our application would not change at all. Just recompile.
source share