Search code examples
c#wcfpublishauto-update

Automating publishing WCF services and updating its references


Even this is not a critical issue, I am having some serious malfunctionings because of some user errors, so I need to find a solution to this problem.

I have a layered service based application. The least degree of layers is 2 in my architecture. So when I make a change that requires reference updating on clients, I need to publish first layer then update reference of first layer on second layer, then publish second layer after that update reference of second layer on client application. If this was all I had to do I believe I could survive, but I have 5 different services like this and everyone of them has implementation and production environments to publish. And I easily get confused with these steps.

When I did a quick research I found thinds like built script. But since in my case there is update service reference operation too, I'm not sure if it would work. So I am asking for a tool, or an approach to publish services and update references in some certain orders.


Solution

  • We had the same problem with updating service references for a dozen of services.

    If your service and client projects can share a common service contract DLL (have a project reference to project with service types), you can use channel factory for creating clients. In this case you will not need service references at all.

    BasicHttpBinding myBinding = new BasicHttpBinding();
    EndpointAddress myEndpoint = new EndpointAddress("http://localhost/MathService/Ep1");
    ChannelFactory<IMath> myChannelFactory = new ChannelFactory<IMath>(myBinding, myEndpoint);
    IMath wcfClient1 = myChannelFactory.CreateChannel();
    double s = wcfClient1.Add(3, 39);
    ((IClientChannel)wcfClient1).Close();
    

    You can read more there http://philmunro.wordpress.com/2012/02/15/creating-a-wcf-service-proxy-with-channelfactory/