What is DataContract and ServiceContract?Explain

Answer Posted / vijay krishna

Data represented by creating DataContract which expose the
data which will be transefered /consumend from the serive
to its clients.

**Operations which is the functions provided by this
service.

To write an operation on WCF,you have to write it as an
interface,This interface contains the "Signature" of the
methods tagged by ServiceContract attribute,and all methods
signature will be impelemtned on this interface tagged with
OperationContract attribute.

and to implement these serivce contract you have to create
a class which implement the interface and the actual
implementation will be on that class.


Code Below show How to create a Service Contract:

[ServiceContract]
Public Interface IEmpOperations
{
[OperationContract]
Decimal Get EmpSal(int EmpId);

}

Class MyEmp: IEmpOperations
{
Decimal Get EmpSal()
{
// Implementation of this method.
}
}

Hope now you can differentiate between Data
Contract,Service Contract and OperationContract.

Is This Answer Correct ?    22 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many Instance modes is supported by WCF?

557


What is data contract equivalence?

557


Elucidate on the various contracts in wcf?

506


What are the protocols supported by wcf hosting environment?

519


How to do authentication in wcf?

530






Explain service contracts?

541


what is DataContractSerializer?

550


What is address in wcf and how many types of transport schemas are there in wcf?

534


What is msmq binding?

534


WCF:What is it the Reliable session?

1544


What are the features of wcf?

552


explain duplex ws binding? : Wcf data services

499


What is the basic difference between creating WCF service or WEB services?

542


What is the "address" property of endpoint in wcf?

528


explain wcf basic binding type? : Wcf data services

498