Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do WCF callbacks work over HTTP?

Tags:

http

wcf

It is my understanding that in HTTP the client connects to the server and requests data. The server cannot call the client. If this is the case then how do WCF callbacks work?

Thanks,

Joe

like image 849
JoeS Avatar asked Nov 01 '11 09:11

JoeS


People also ask

What is a WCF callback?

Abstract: In WCF, callback is used to implement PUSH mechanism, so that delayed or long running operation results can be automatically pushed back to the client application. WCF actively supports callback to its client, over the instance context established.

Which HTTP binding is used for duplex contracts?

This is the WsDualHttpBinding. This binding is designed for use with Duplex Service contracts, which allows both the Services and clients to send and receive the messages.

Do you need to use session object explicitly in duplex WCF service?

A duplex contract does not require a session, although the system-provided duplex bindings make use of them.

What is duplex communication in WCF?

A duplex contract allows clients and servers to communicate with each other independently so that either can initiate calls to the other. The duplex contract is one of three message patterns available to Windows Communication Foundation (WCF) services. The other two message patterns are one-way and request-reply.


1 Answers

When used with HTTP transport the server does call the client. In order to get this to work the client must be on a public endpoint, so firewalls and what-have-you will need to be configured appropriately.

From http://msdn.microsoft.com/en-us/magazine/cc163537.aspx:

Because of its connectionless nature, HTTP can't be used for callbacks and therefore you can't use callbacks over BasicHttpBinding or WSHttpBinding. Windows Communication Foundation offers callback support for NetTcpBinding and NetNamedPipeBinding because the underlying transport is bidirectional. To support callbacks over HTTP, Windows Communication Foundation provides 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.

And from the reference for WSDualHttpBinding http://msdn.microsoft.com/en-us/library/system.servicemodel.wsdualhttpbinding.aspx:

This binding requires that the client has a public URI that provides a callback endpoint for the service. This is provided by the ClientBaseAddress. A dual binding exposes the IP address of the client to the service. The client should use security to ensure that it only connects to services it trusts.

like image 114
Jeremy McGee Avatar answered Oct 07 '22 22:10

Jeremy McGee