Search code examples
wcfcallbacknettcpbinding

WCF callbacks for NetTCP binding


I would like to add callbacks to my WCF service, so that my client can receive notifications of certain server events. I found a beginner's guide to callbacks: http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx, but this seems to only apply to HTTP binding.

Any ideas?


Solution

  • Actually, it doesn't apply to a regular HTTP binding (which is one-way), only wsDualHttpBinding, which is a special binding not typically supported on platforms other than .NET. Using callbacks with NetTCP is as easy as changing

    <endpoint address ="" binding="wsDualHttpBinding" contract="WCFCallbacks.IMessage">
    

    to

    <endpoint address ="" binding="netTcpBinding" contract="WCFCallbacks.IMessage">
    

    and

    <baseAddresses>
        <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WCFCallbacks/Message/" />
    </baseAddresses>
    

    to

    <baseAddresses>
        <add baseAddress = "net.tcp://localhost:8731/Design_Time_Addresses/WCFCallbacks/Message/" />
    </baseAddresses>
    

    Just make sure whatever port you use isn't already bound to by another process on your system, such as IIS (unless you plan to host your service inside IIS).