O'Reilly logo

Programming WCF Services by Juval Lowy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Callback Operations

WCF supports allowing the service to call back to its clients. During a callback, in many respects the tables are turned: the service is the client and the client becomes the service (see Figure 5-1).

A callback allows the service to call back to the client

Figure 5-1. A callback allows the service to call back to the client

The client also has to facilitate hosting the callback object. Callback operations can be used in a variety of scenarios and applications, but they are especially useful when it comes to events, or notifying the clients that some event has happened on the service side. Not all bindings support callback operations. Only bidirectional-capable bindings can be used for callbacks. For example, because of its connectionless nature, HTTP cannot be used for callbacks, and therefore you cannot use callbacks over BasicHttpBinding or WSHttpBinding. WCF offers callback support for NetTcpBinding and NetNamedPipeBinding, because by their very nature, the TCP and the IPC protocols support duplex communication. To support callbacks over HTTP, WCF offers the WSDualHttpBinding, which actually sets up two HTTP channels: one for the calls from the client to the service and one for the calls from the service to the client.

Callback Contract

Callback operations are part of the service contract, and it is up to the service contract to define its own callback contract. A service contract can have at most one callback contract. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required