Discover a Service with Unique Listen Uri Mode Sample

This sample demonstrates how to discover a service that has the ListenUriMode property set to Unique. When the ListenUriMode property is set to Unique, the ListenUri is ensured to be unique by either setting the port to be unique or for the path to be unique by appending a GUID.

Features on the Service

The ListenUriMode property is set to Unique for the TCP endpoint. The service is then made discoverable over a UdpDiscoveryEndpoint endpoint.

Features on the Client

This client connects to the service using the correct Via.Uri by using the Find method. The FindResponse that is returned from the method is then queried for whether it contains a valid ListenUri and whether it is different than Address.Uri. The appropriate information is then passed to the InvokeCalculatorService method. In the InvokeCalculatorService method, the ListenUri was passed in by the caller, then a ClientViaBehavior with the correct Via.Uri is added to the client’s endpoint.

To use this sample

  1. Using Visual Studio 2010, open UniqueListenUriMode.sln.

  2. To build the solution, press CTRL+SHIFT+B.

  3. Run the service application, which is generated in the [solution base directory]\service\bin\debug folder.

  4. Run the client application, which is generated in the [solution base directory]\Client\bin\debug folder.

    The client locates the running service and writes to the console the metadata published by the service’s endpoint.

Ee530015.Important(en-us,VS.100).gif Note:
The samples may already be installed on your machine. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WCF\Basic\Discovery\UniqueListenUriMode