WS-Discovery in WCF - .NET 4.0

Back in the early beta days of “Indigo”, before WCF, I saw an early demo using WS-Discovery.  The feature obviously was not included in .NET 3.0 or .NET 3.5, but looks like it is in the list of features targeted for .NET 4.0.  Very cool.

WS-Discovery fills a needed gap, providing a standard way to discover services in a network.  The spec is surprisingly short, sine there are only 4 operations:

  • Hello – sent by the service to announce it has joined the network.
  • Bye – sent by the service to announce that it is leaving the network. 
  • Probe – sent by the client to search for a service by type or scope.
  • Resolve – sent by the client to search for a service by name.

A simple way to think of this is a printer.  You install a new printer to the network, and it sends a one-way Hello message to all the nodes on the network.  A new client joins the network and can issue a Probe request asking for all printers in the marketing department’s subnet.  The client can also send a Resolve request asking for a specific printer by name (think of DNS resolution here).  Finally, we decommission the printer and take it off the network, causing the printer to try to send a Bye one-way notification telling everyone that it is being taken off the network. 

How this is done is typically over UDP.  This makes sense… you want an easy way to blast notifications in the Hello and Bye cases, doing so in a multicast fashion without bottlenecking an intermediary service.  UDP is a great protocol for this.

You can learn more about WS-Discovery and the WCF implementation in .NET 4.0 via the 10-4 show on Channel9.

clip_image002

Episode 19: Service Discovery with WCF

WCF in .NET 4 includes an implementation of the WS-Discovery protocol.  Sounds exciting right?  Actually it is very cool because it allows you to build applications and services that can discover other services using UDP multicast messages or via a discovery proxy.  In this episode I'll walk through the Service Discovery lab where we build a messenger style application I call "ChatWOW".  In this lab you will see how to make your service discoverable and how you can discover other services.