Can you show a sample of Duplex Contract in WCF ?

 Posted by Akiii on 5/18/2012 | Category: WCF Interview questions | Views: 5461 | Points: 40
Answer:


[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.



Thanks and Regards
Akiii


| Alert Moderator 

Comments or Responses

Login to post response