How do WCF calls work on HTTP?

As far as I understand, in HTTP the client connects to the server and requests data. The server cannot call the client. If so, how do WCF callbacks work?

Thanks,

Joe

+6
source share
2 answers

When used with HTTP transport, the server calls the client. For this to work, the client must be in a public endpoint, so firewalls and something will need to be configured accordingly.

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

Due to its contactless nature, HTTP cannot be used for callbacks, and therefore you cannot use callbacks through BasicHttpBinding or WSHttpBinding. The Windows Communication Foundation offers callback support for NetTcpBinding and NetNamedPipeBinding, because the underlying transport is bidirectional. To support callbacks over HTTP, the Windows Communication Foundation provides WSDualHttpBinding, which actually sets up two HTTP channels: one for calls from client to service and one for calls from service to client.

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

This binding requires the client to have an open URI that provides a callback endpoint for the service. This is provided by ClientBaseAddress. Double binding provides the client IP address to the service. The client must use security to ensure that it only connects to services that it trusts.

+6
source

The WCF duplex HTTP client (for example, when using wsDualHttpBinding ) will also start the server to listen for requests from the "real" server when it is called back.

Thus, this will not work on NAT, to name one.

0
source

Source: https://habr.com/ru/post/900494/


All Articles