• Feeds

    Subscribe in a reader

  • Ads

AddressFilterMode.Prefix

By default, the WCF dispatch runtime will match messages to their destination endpoint using an exact matching algorithm on the message's To: header.

This means that if you have a service endpoint listening at http://foo.com/endpoint1/, messages addressed to http://foo.com/endpoint1/somethingElse will return an EndpointNotFound fault. Conceptually, your endpoint is listening on exactly one URI and if the wsa:To header doesn't match that URI, the messages ain't going to get there.

However, in fairly recent bits (the July CTP), we introduced the ability to do the following:

[ServiceBehavior( AddressFilterMode = AddressFilterMode.Prefix )]
public class Foo : IFoo
{
}

Setting AddressFilterMode.Prefix on [ServiceBehavior] will cause the runtime to use a longest-prefix matching algorithm to match messages to the endpoint. In this mode, the wsa:To URI just has to start with the endpoint URI; it doesn't have to match exactly. This implies that your endpoint is actually listening on an open set of URI's instead of just one. This is the mode to use if you want your endpoint to listen not only on /foo, but /foo/bar, /foo/baz, /foo/bar/baz, etc.

Given that the address URI of the incoming message is always available in the scope of an operation via OperationContext.Current.IncomingMessageHeaders.To, this opens up some very cool possibilities for people who want to address messages to "the thing being processed" instead of "the thing doing the processing".