What is DataContract and ServiceContract?Explain

Answers were Sorted based on User's Feedback



What is DataContract and ServiceContract?Explain..

Answer / 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

What is DataContract and ServiceContract?Explain..

Answer / pradeeprajasekharan

ServiceContract

Defines the Interface that is exposed through end points
which says what functionality will be available for the
client. So the ServiceContract attribute will be placed in
the interface level. Interface contains the definition of
the available methods through the service.

OperationalContract

Defines the methods under the service.


DataContract

Defines the mapping between CLR datatypes with XSD schema.
The complex datatypes will be serialized and deserialized
according to the DataContact attribute associated.

Is This Answer Correct ?    13 Yes 3 No

What is DataContract and ServiceContract?Explain..

Answer / sandeep

Service Contract:
Service contracts describe the operation that service can
provide. For Eg, a Service provide to know the temperature
of the city based on the zip code, this service is called as
Service contract. It will be created using Service and
Operational Contract attribute.

Data Contract:

Data contract describes the custom data type which is
exposed to the client. This defines the data types, that are
passed to and from service. Data types like int, string are
identified by the client because it is already mention in
XML schema definition language document, but custom created
class or data types cannot be identified by the client e.g.
Employee data type. By using DataContract we can make client
to be aware of Employee data type that are returning or
passing parameter to the method.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More WCF Interview Questions

explain duplex ws binding? : Wcf data services

0 Answers  


What is REST and what is the problem with WCF REST and how it can be resolved?

0 Answers  


Why is there a requirement of wcf for the enhancement of various business services?

0 Answers  


Explain data contracts?

0 Answers  


How many types of various programming approaches used for WCF?

0 Answers   Viscus Infotech,






What are the 3 ways of implementing WCF(Windows Communication Foundation) concurrency?

0 Answers   QuestPond,


WCF:Is the MsmqIntegrationBinding used the msmq.formatname scheme or the net.msmq scheme?

1 Answers  


WCF:What types of reliable messaging are implemented in the WCF?

0 Answers  


Please explain briefly different instance modes in wcf?

0 Answers  


What is overloading in wcf?

0 Answers  


explain data contracts? : Wcf data services

0 Answers  


What are the different platforms where we can host wcf service ?

0 Answers  


Categories