.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> WCF >> Post New Question Subscribe to Interview Questions

What are Duplex Contracts in WCF?

Posted By :Subhransu Sekhar Jena     Posted Date :September 30, 2014    Points :40   Category :WCF 
WCF Services can communicate with client through a called duplex messaging pattern commonly known as callback. Duplex messaging in WCF can be done over different transports, like TCP, Named Pipes and even HTTP. This is collectively known as Duplex Contracts in WCF.

You can also find related Interview Question to What are Duplex Contracts in WCF?  below: 

What are code contracts?

  
Code contracts help you to express the code assumptions and statements stating the behavior of your code in a language-neutral way. The contracts are included in the form of pre-conditions, post-conditions and object-invariants. The contracts help you to improve-testing by enabling run-time checking, static contract verification, and documentation generation.

The System.Diagnostics.Contracts namespace contains static classes that are used to express contracts in your code. (More...)

What is the use of Is Required Property in Data Contracts?

  
Data Contracts, is used to define Required or NonRequired data members. It can be done with a property named IsRequired on DataMember attribute.

When IsRequired property is true you must populate that datamember before passing it.

[DataContract]

public class test

{

[DataMember(IsRequired=true)]

public string NameIsMust;



[DataMember(IsRequired=false)]

public string Phone;

}

(More...)

What is duplex contract in WCF?

  
In Duplex contract, clients and servers can communicate with each other independently.

Duplex contracts consists of two one-way contracts so that parallel communication is achieved.
(More...)

Can you show a sample of Duplex Contract in WCF ?

  

[ServiceContract(Namespace = "http://www.Microsoft.com",

SessionMode = SessionMode.Required,

CallbackContract = typeof(IDuplexCallBack) )]



public interface IService1

{

[OperationContract(IsOneWay = true)]

void getData();

}



public interface IDuplexCallBack

{
[OperationContract(IsOneWay = true)]

void filterData(DataSet Output);

}


In the above code, getData() is a method which will be called by the client on the Service. This getdata() is implemented in the server side.

filterData() is a method which will be called by the server on the Client. This method is implemented in the client side.

CallbackContract is the name of the contract which will be called by the server on the client to raise an event or to get some information from the client.
(More...)

State 3 Duplex contract problems in WCF ?

  
(1) Threading problems can occur if either of the Callback channels are not empty.

(2) If the client and service has a long running work then this pattern doesn't scale very well. It can block the client or the service until the process is completes !

(3) It requires a connection back to the client. And there may be a chance to not connect back due to firewall and Network Address Translation problems.


Note :- It is always better to use Request / Response MEP rather than using Duplex method.
(More...)

What are Contracts in WCF?

  
A Contract is basically an agreement between the two parties i.e. Service and Client. In WCF, Contracts can be categorized as behavioral or structural.
1. Behavioral Contracts define that whatoperationsclientcanperform on a service.
o ServiceContract attribute is used to mark a type as Service contract that contains operations.
o OperationContract attributes is used to mark the operations that will be exposed.
o Fault Contract defines what errors are raised by the service being exposed.
2. Structural Contracts
o DataContract attribute define types that will be moved between the parties.
o MessageContract attribute define the structure of SOAP message.
(More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend