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 to configure reliability while communicating with wcf services?

470


what is wcf peer network binding type? : Wcf data services

433


How to host WCF Self-Hosting?

520


Explain the wcf ria?

460


Explain data contracts?

445






What is datacontractserializer and how its different from xmlserializer?

474


What is the proxy for wcf service?

497


Explain fault contracts?

471


What are the transport schemes supported by wcf? Give example of address for each scheme.

480


Elucidate on the various contracts in wcf?

440


Define message contracts?

495


What are wcf service endpoints? Explain.

444


what is windows card space?

558


How we can use MessageContract partially with DataContract for a service operation in WCF?

511


Explain wcf tcp binding type?

487