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

What are the types of messaging programs?

606


How many types of transport schemas are there in wcf?

436


what are the MEPs available in WCF?

451


What are the essential components used in wcf?

440


What are the wcf service endpoints?

438






What is overloading in wcf? How to do authentication in wcf?

472


How would you generate a proxy for wcf?

456


What is the request-reply mode in wcf?

496


What is wcf federated ws binding type?

434


What are the different types of transaction managers supported by wcf?

411


Explain use of Endpoints in WCF Service?

513


What is transport reliability in wcf?

488


What are the Advantages of hosting wcf in iis?

495


What message exchange patterns (meps) supported by wcf?

457


Exp wcf peer network binding type?

449