Saturday, February 19, 2011
WCF Interview Questions on Contracts - Part 1
Click here for all SQL Server Interview Questions
Click here for all WCF Interview Questions
Click here for all ASP.NET Interview Questions
Click here for all C# Interview Questions
Click here for Written Test or practical ASP.NET Interview Questions asked in MNC's
Define Service Contracts and Operation Contracts in WCF?
1. Service Contract - An interface that exposes the service operations is usually decorated with the service contract attribute. Always provide meaningful Namespace and Name to a service contract as shown in the example below.
2. Operation Contract - All methods in a service contract should have OperationContract attribute. You can also provide explicit Name, Action and ReplyAction as shown in the example below.
Can you apply, ServiceContract attribute to a class rather than an interface in WCF?
Yes, a ServiceContract attribute can be applied either to a class or an interface, but defining service contracts using interfaces rather classes has the following benifits.
1. Defining service contracts using interfaces, removes coupling to service implementation. Later the implementation can be changed at will without affecting the clients.
2. Defining service contracts using interfaces, also allows a service to implement more than 1 contract.
What is the purpose of MessageParameter attribute in WCF?
MessageParameter attribute is used to control the parameter and returned object names from a service operation. Consider the example below. On the service side, the method parameter name in SaveCustomer([MessageParameter(Name = "Customer")] Customer cust) is cust. If we donot use MessageParameter attribute, then "cust" is what is exposed as parameter name to the client, which is not very proffesional. So we are using MessageParameter attribute to expose the method parameter name as Cutomer.
Click here for all SQL Server Interview Questions
Click here for all WCF Interview Questions
Click here for all ASP.NET Interview Questions
Click here for all C# Interview Questions
Click here for Written Test or practical ASP.NET Interview Questions asked in MNC's
Subscribe to:
Post Comments (Atom)
What is the main use of Datacontract serilization when compare to XML Serialization
ReplyDeletehi,
Deletewhen web service xml serialization compare to datacontract serilization is better security,relability and transcation support.
XML serialization serializes all the members of the class where as datacontract ensures only to serialize members which are decorated with datamember
DeleteAlso, the order of serialization can be specified when we use datacontract-datamember model
Can 5 GB data be transferred through WCF?
ReplyDeleteHi All,
ReplyDeleteUnable to understand the 1st benefit, How it is useful for the 1st point please can you explain with any example
Contract attribute to a class rather than an interface in WCF?
Yes, a ServiceContract attribute can be applied either to a class or an interface, but defining service contracts using interfaces rather classes has the following benefits.
1. Defining service contracts using interfaces, removes coupling to service implementation. Later the implementation can be changed at will without affecting the clients.