简体   繁体   中英

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?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM