What is Service Contract in WCF?

Contracts in WCF are very important. Contracts are responsible for how to communicate, what protocol to use and what message to send.

Following contracts available in WCF:

  • Service Contract
  • Operation Contract
  • Data Contract
  • Message Contract
  • Fault Contract

We will see all contract one by one with the help of practical implementation in C# code.
Lets start with Service Contract.

Service Contract : Service Contract is nothing but the interface.Service Contract contains the operation that WCF service will have. A WCF service can have more than one Service Contract but must have at least one Service Contract.

A simple Service Contract will look like this.

[ServiceContract]
public interface ICalculate
{
   //Operation Contract
}


Comments

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX