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

Is it possible for a WCF service to implement Multiple service contracts?

507


What is the usage of "receivetimeout" property in wcf?

454


How can we achieve operation overloading in WCF service?

504


What is endpoint in wcf?

490


What are wcf service endpoints? Explain.

448






How would you enable the metadata information of the service?

479


can you explain how to define a service as rest based service in wcf? : Wcf data services

437


explain msmq integration binding? : Wcf data services

424


What does a windows communication foundation, or wcf, service application use to present exception information to clients by default?

546


What is the transport and message reliability?

510


What is the difference wcf and web services?

452


WCF:What is it the Net.TCP Port Sharing? How can we use it?

3204


tell me what was the code name for wcf? : Wcf data services

431


WCF:What is it the Teredo? How can we use it?

3082


Explain service contracts?

470