Explain contract and all types of contract in WCF?

 Posted by Sumank on 5/10/2013 | Category: WCF Interview questions | Views: 3204 | Points: 40

Contract is platform-neutral and standard way of describing what services does. In WCF, all services are exposed as contract. There are four types of contracts :

Service Contract – It describes operation provided by service. A service should contain at least one service contract. Service Contract is defined by using [ServiceContract] attribute , it is similar to [WebMethod] of Web Services.

Data Contract – It describes data exchange between service and client. Data Contract is defined using [DataContract] and [DataMember] attribute.

Message Contract – It transfers information from service to client. WCF uses SOAP message format for communication.

Fault Contract – It handles and convey error message to the client when service get error.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response