i am new but reading some article on wcf i came to know that if i change the ServcieContrcat
then i 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
[ServiceContract]
public interface IOrderService
{
[OperationContract]
Order GetOrderById(int orderId);
[OperationContract]
List<Order> GetOrdersByStatus(OrderStatus orderStatus);
[OperationContract]
void SaveOrder(Order order)
}
after few 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
one guy answered before for the same situation
This is what I did: All of my 30+ functions (and the list grows and grows) took strings, ints and bytes() as data types as both input and output parameters, I created a master single endpoint and function that receives, as an input parameter, and sends back as the output, a single simple class. This class, called HostInterface, contains just two parameters, a string (which I use to encapsulate all my strings and ints) and a byte() array (into which I stuff all my binaries)
So, whether a client is calling something simple like Ping() with just one string param, or something complicated like ResumeDownload() with 5 strings, 2 ints and a byte array, all of those parameters get encapsulated in my HostInterface class, the strings and ints into the one String parameters (as XML) and the bytes into the byte field.
i appreciate his answer but really do not understand how to implement it. so if anyone go to this url How to change WCF service contract which does not effect client?
then knows what he said.
i am looking for small complete wcf service code which help me to visualize how to design service contract in such way that if we extend the functionality of service contract later then client who will consume my service will not face any problem.
and tell me other possible guide line to solve this situation. thanks