Home > WCF > Callback in WCF using wsDualHttpBinding

Callback in WCF using wsDualHttpBinding

When shall we go for wsDualHttpBinding?

Your service need to perform lot of operation after getting the information from the client side, which consume more time to return result back to the client.

Normally time consuming operation in server side will block the client to perform other operation. So  ‘wsDualHttpBinding’ will be ideal solution for this kind of problem.

Suppose if your client not depend on the result produce by the service at that time we can go for ‘wsDualHttpBinding’ .

If you need to implement callback between client and service at that time we can go for ‘wsDualHttpBinding’.

Because of some operation (or) result taking place in server side must not affect the client side access or other request the ideal choice is ‘wsDualHttpBinding’

wsDualHttpBinding is binding which sends the request in one http channel and response will be sent back to the client in another http channel

 

If you are using ‘dualHttpBinding’ you need to create two interface one interface is to get the request from the client and one more is send the response back to the client as callback

The below mentioned interface is to send the response back to the client and the ‘OperationalContract’ used to send the response back to the client must be decorated with the property ‘IsOneWay=true’ as shown below.

CalbackInterface

Another Interface mentioned below is to get the request from the client, this interface  must also be decorated with the property ‘IsOneWay=true’  inside the ‘OperationalContract’ attribute as mentioned below. Also we need to refer using which interface (or) channel we are going to send the response back to the client. We already declare the callback interface now need to establish relationship with the ‘ServiceContract’ as mentioned below.

ServiceContract

In the above code we are mentioned ‘INotificationServiceCalback’ as the callback interface by using ‘CallbackContract’ property of ServiceContract.

 

In the web.Config we need to specify ‘wsDualHttpBinding’ in the binding property.

WebConfig

 

The Implementation of service contract

ImplementationofDuplex

You can find the Code sample here

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: