Update all links to WCF services in one click (two clicks will be fine too!)

I have several projects containing multiple WCF service references.

My WCF services are in a state of change, so I often have to get around and updating all my service links.

Is there a way to achieve this as a single action?

+4
source share
3 answers

Well, rather than using an IDE, can you use svcutil on the command line through a build script? Then all you have to do is restart bat / script / whatever ...

+6
source

I do not use generated proxies at all. I just have a general assembly between my client and server that defines the interfaces to the service contract + next sleight of hand.

  // this class can be used to instantiate a unidirectional proxy (one that doesn't require callbacks from the server) public class UniDirectionalServiceProxy<T> : System.ServiceModel.ClientBase<T> where T : class { public UniDirectionalServiceProxy() { } public UniDirectionalServiceProxy(string endpointConfigurationName) : base(endpointConfigurationName) { } public UniDirectionalServiceProxy(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public UniDirectionalServiceProxy(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public UniDirectionalServiceProxy(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } // new keyword allows us to supercede the inherited protected member and make it public. public new T Channel { get { return base.Channel; } } } 

It looks good, right? Create this object, and then just modify your calls to use the channel member.

You can also use ChannelFactory to get the same result (I suppose they made Channel a protected member of ClientBase to encourage developers to use ChannelFactory), but I prefer this mechanism, since you end up with one object that encapsulates communication control and calls through the wire. Obviously, this way you lose the async methods from svcutil, but this is very easy to do with delegates.

+1
source

I prefer not to set WCF service references through the IDE mechanism if I can avoid this. I'd rather just provide proxies in a separate class library. Thus, what usually happens is that updating from the source code repository will disrupt the local copy assembly, and then it will be obvious that something needs to be changed. In the end, it should be as painful as any public interface. I am not a fan of svcutil.exe.

0
source

All Articles