What is DataContract and ServiceContract?Explain
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
explain wcf ipc binding type? : Wcf data services
What is .svc file in wcf?
When is the msmqintegrationbinding?
What is the difference between xmlserializer and the datacontractserializer?
What is REST and what is the problem with WCF REST and how it can be resolved?
Define message contracts?
What is service host factory in wcf?
Explain the different ways to host wcf service?
what is SOA?
What are the advantages of using wcf?
How many types of various programming approaches used for WCF?
How many types of binding are there in wcf?