Click here to Skip to main content
15,889,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can we define a class as a ServiceContract or ServiceContrcat should be always a interface?
Posted

1 solution

See here:http://msdn.microsoft.com/en-us/library/ms733070.aspx[^]

Quote:
Both classes and interfaces represent a grouping of functionality and, therefore, both can be used to define a WCF service contract. However, it is recommended that you use interfaces because they directly model service contracts. Without an implementation, interfaces do no more than define a grouping of methods with certain signatures. Implement a service contract interface and you have implemented a WCF service.
All the benefits of managed interfaces apply to service contract interfaces:

  • Service contract interfaces can extend any number of other service contract interfaces.
  • A single class can implement any number of service contracts by implementing those service contract interfaces.
  • You can modify the implementation of a service contract by changing the interface implementation, while the service contract remains the same.
  • You can version your service by implementing the old interface and the new one. Old clients connect to the original version, while newer clients can connect to the newer version.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900