This is one my favorite WCF features that I've stumbled across lately. Kenny was the first
to mention it on his blog. It basically solves the challenge of generating a "unique" address for an endpoint when you don't know what's already in use. Here's how it works:
<configuration>
<system.serviceModel>
<services>
<service name="WcfTests.MathService">
<endpoint listenUriMode="Unique"
address="net.tcp://localhost/math"
binding="netTcpBinding"
contract="WcfTests.MathService"/>
</service>
</services>
</system.serviceModel>
</configuration>
Using this configuration with TCP endpoints causes WCF to automatically choose a "free" port number -- it also appends a unique GUID to the end of the address to ensure uniqueness. For HTTP and named pipes it only appends the GUID to the address, it doesn't generate a unique port number.
When I run this configuration, the listener address for this endpoint is:
net.tcp://localhost:39619/math/908ae8dc-7427-407a-9ea4-8aeecdfa62be
The default for listenUriMode is "Explicit", which allows you to "explicitly" control the addresses.
Posted
Apr 24 2006, 07:05 PM
by
Aaron Skonnard