How to change WCF service contract which does not effect client c# RRS feed

  • Question

  • User88744855 posted

    i am new but reading some article on wcf i came to know that if you change the ServcieContrcat then you have to change not only the Service end but Clients end too and it's really difficult to manage.

    Example 1:

    Developer have to create WCF service for Order processing, with following function: GetOrderById, GetOrdersByStatus, SaveOrder

    The ServiceContract could looks like following

    public interface IOrderService
        Order GetOrderById(int orderId);
        List<Order> GetOrdersByStatus(OrderStatus orderStatus);
        void SaveOrder(Order order)

    after month, for example, project manager say: Ok, our customers need another functions: DeleteOrderById, GetOrdersByCustomerId and don't need GetOrdersByStatus any more, we need GetOrdersByStatusAndCustomerId

    Developers have to update ServiceContrcat and update client. As you can see, any changes in the ServiceContrcat is really difficult

    so i am looking for best guidance how to develop wcf service which will not create any problem if we extend the functionality or any kind of change but client end will not face any problem. thanks

    Thursday, January 23, 2014 6:09 AM

All replies

  • User25800215 posted

    Yes I agree it is problamatic, In Such scenarios, I think you can create new interface and implement the service for 2nd interface as well. Off-course still u have to generate proxy at consumer end but doesn't require to change existing clien code as long as you are injecting the with parent/interface object.

    Other way of implementation is initially, you can add predictable operation contracts and implement them with notimplemented exception. whenerver it is required to update then update the code, in such cases you don't need to change client code but it is not a good design principle.

    My 2 cents

    Thursday, January 23, 2014 12:03 PM