Author Archives: kenny

Exposing Capabilities on your Binding

Bindings represent a wide variety of functionality. Everything from different transports, to different security mechanisms, delivery mechanisms, transactions, and custom protocols. Nonetheless, there are times where you want to make a decision based on a binding’s capabilities.

For example: “Does this binding support ordered delivery?”
Or: “Does this binding support both client and server authentication?”

WCF has a polymorphic way of making such inquiries of a Binding, though there are a few subtleties involved.

The first pivot point is to decide whether the capability is a property of the actual Binding, or a property exposed by the stack of Binding Elements. For example, supporting client authentication is a property of the underlying stack. It can be added at different layers (e.g. transport, WS-Security, etc), and can even be removed by some layers. These capabilities are accessed though a method on the Binding:

T GetProperty<T>()

As in:

ISecurityCapabilities s = binding.GetProperty<ISecurityCapabilities>();

GetProperty<T> simply constructs a Binding Context representing the stack of Binding Elements, and queries them through:

T GetProperty<T>(BindingContext context)

Each individual Binding Element can handle the inquiry itself, delegate the inquiry, or a combination of the two. GetProperty is also supported by the runtime objects (IChannelFactory, IChannelListener, IChannel, etc).

Conversely, if a Binding claims to support Basic Profile 1.0, that is a claim about a particular coordination and configuration of binding elements. Therefore, this is not a feature to expose through T GetProperty<T>(). The Binding should instead implement the capability directly. For example:

public class MyBasicProfileBinding : IBasicProfile10Binding

Where IBasicProfile10Binding is an agreed upon interface. It is queried as “if (binding is IBasicProfile10Binding)

Lastly, there are a handful of cases where a particular property is applicable to all bindings. In that case, we use the traditional approach of a strongly typed property on our base class. For example:

public abstract string Scheme { get; }

To re-cap: for polymorphic properties, use GetProperty<T>. For capabilities of the binding element stack, and interface implementation for composite capabilities provided by the concrete binding.

Guitar Hero

Sunday we were at Julie and Damian’s place for brunch. The pancakes and mimosas were awesome, but what stole the show was Damian’s latest toy — Guitar Hero, a “revolution”-esque game where you get to be the lead guitarist in a band, and there’s a guitar controller that you use. It was awesome.

Unfortunately, they don’t make an x-box version yet. The word from Red Octane in October was that “It’s seriously being considered, but things also can’t exactly happen overnight because you’ll need a guitar controller.” Well, it’s April now and while they’ve announced Guitar Hero II for the PS-2 this November, still no sign of an x-box release. Fortunately Julie and Damian love visitors 🙂

Jalisco (Seattle, WA)

Rating:

One of the things I love about my area of Capitol Hill is that I am walking distance from a variety of restaurants. Almost everytime LL and I walk to Jamjuree or 22 Doors or QFC we pass Jalisco’s, mention that we should check it out, but then continue on. Tonight we decided that after almost 3 years in this neck of the woods it was time to sample the neighborhood Mexican fare.

The food was very disappointing. This is not Mexican food. It’s a step up from Taco Bell (though without the ghetto pleasure there), and not even at the Taco Del Mar level. The cheddar on the enchiladas had almost an american cheese consistency, the sauces had no spice and minimal flavor, and the tortillas were maybe on par with what you buy at QFC: definitely not freshly made. Next time we’re hankering for nearby Mexican we’ll walk down to Galerias or Guaymas, or hop in the car to Gordito’s 🙂

Jalisco Mexican Restaurant
1467 E Republican St
Seattle, WA 98112
206-325-9005

Sun-Th: 11:00AM-10:00PM, Fri-Sat: 11:00AM-11:00PM (Lunch and Dinner)

Configuration Http Proxies in WCF

When using Http, proxy configuration madness is a fact of life. If misconfigured, you can wind up trying to decipher obtuse 502 (Bad Gateway) and 504 (Gateway Timeout) errors.

Fortunately there are a number of binding settings available in WCF to control your Http proxy usage. These settings are available directly on BasicHttpBinding and WsHttpBinding (as well as on HttpTransportBindingElement when you are using a CustomBinding).

  • public bool UseDefaultWebProxy (default == true): if set to true, will use the global value HttpWebRequest.DefaultProxy as your proxy. HttpWebRequest.DefaultProxy is controllable through System.Net config, and defaults to using the system proxy settings (i.e. when you see in your Internet Explorer properties).
  • public Uri ProxyAddress (default == null): If you want to specify a proxy directly you can set a proxy Uri directly here. To ensure no proxy is used you can specify “null” here. In both cases be sure to set UseDefaultWebProxy = false as well.
  • public bool BypassProxyOnLocal (default == false): used in conjunction with ProxyAddress for when you specify a proxy. If you want “local” addresses (i.e. addresses on your intranet) to connect directly without using the proxy, set this value to true.
  • public HttpProxyCredentialType HttpTransportSecurity.ProxyCredentialType (default == None): Specifies the authentication mode used with your Http proxy. For custom bindings the equivalent setting is public AuthenticationSchemes ProxyAuthenticationScheme (default == Anonymous) on HttpTransportBindingElement. For proxy authentication we will obtain the credential using the shared WCF provisioning framework (SecurityTokenProvider, etc). We simply pass in the proxy address (rather than the target address) for acquiring these credentials.

One last note about proxies: if you see a 502 or a 504 error returned to your client, then your client is using a proxy server. If this was not your intention, you can disable the server by setting UseDefaultWebProxy to false, and using the default ProxyAddress of null. The other possibility is that your proxy is misconfigured and you can use the above settings to rectify that situation 🙂

Channel Authors unite!

Hot off the presses is a new resource for channel authors: the WCF Custom Channel Resources page at wcf.netfx3.com. This is a great portal for samples, documentation, and all things Channel-related.

The samples page contains updated versions of our PDC demos (WSE 3.0 TCP Interop and Chunking Channel) as well as new helpers for testing and generating config for your channels. Check it out!

UPDATE (06/21/06, 3:50P): updated links to point to our new community website

Ray's Boathouse Restaurant (Seattle, WA)

Rating:

March almost passed me by without my noticing that it was a Twenty-Five for $25 month. We’re managing to slide into home in the last two days of the promotion at Ray’s and then tonight at Restaurant Zoe.

Mike showing off the salmonThe last time I was at Ray’s was in 1998, and I had memories of a gorgeous view of the Olympic mountains and great seafood dining. Things have changed. The restaurant is now on the shore just south of Golden Gardens (even more of a schlep than Ballard), upped their prices, and (with the notable exception of their salmon chowder) the food was forgettable.

The promotional menu had lots of choices and with roaming forks I sampled a few dishes for each course. Appetizers included the salmon chowder, a savory cheesecake, and tuna tartare. The chowder was the best I’ve had in Seattle: not too creamy, with a full salmon flavor and bacon-free (so LL was able to partake). The cheesecake was a nice change of pace (lots of cheese and bacon), but the tartare was chewy and tasteless. The kind you might get at a tourist trap venue.

So-so halibut with tasty tomatoesSecond course: I was excited about the halibut, as the Alaskan season has just started and the description was mouth-watering. Unfortunately the only tasty pieces of this nice-looking plate were the juicy fresh tomatoes. The halibut was flavorless, and overcooked. Halibut at its finest is light and flaky and I savor that texture. Perhaps my expectations were too high, but at a menu price of $25.95 in a restaurant supposedly “best of breed” for local seafood I must say it was a disappointment. Mike’s salmon was respectable, and the pesto sauce complemented the natural grilled flavors nicely.

25 for $25 is a great indulgence for your sweet tooth since every list involves an (effectively) free dessert. We tried one of each: Earl Grey crème brulée, coconut cake with fresh fruit, and “strawberry float”. The only one worth a second taste was the crème brulée, and most of its praise is by comparison with the lackluster alternatives. They did make for a nice picture though:

The ladies showing off a trio of desserts

Overall, great company and great chowder, but I won’t be coming back for awhile. I’m looking forward to the contrast tonight when LL and I introduce DeAnn to Zoe’s.

Ray’s Boathouse Restaurant
6049 Seaview Avenue NW
Seattle, WA 98107

Demystifying HostNameComparisonMode: Wildcards, and URI Matching

Today I was asked “what is StrongWildcard and WeakWildcard, and which one should I use?”. The piece of object model that my co-worker is asking about is:

public enum HostNameComparisonMode
{

StrongWildcard = 0,
Exact = 1,
WeakWildcard = 2,

}

Most bindings have a HostNameComparisonMode property on them. This property is used for service-side endpoints (IChannelListener), in conjunction with the ListenUri of that endpoint. The values are semantics similar to + and * for http.sys registrations. “Wildcard” vs. “Exact” refers to how we match the authority (hostname+port) piece of an incoming Uri. For “Wildcard”, anything matches. For “Exact”, we perform a case-insensitive string comparison to determine equality.

“Strong” vs. “Weak” has to do with the relative priorities of endpoints. We use three longest-prefix-match tables, one each for StrongWildcard, Exact, and WeakWildcard. When a Message comes into the system, we first try to match the Uri against our Strong table (which uses a wildcard comparison on hostname+port). If nothing matches, we try the Exact table (using a case-insensitive exact comparison on hostname+port). Lastly, if there was no match on Strong or Exact, we check the Weak table (again using a wildcard match for hostname+port).

For example, let’s say you have the following endpoints registered on your machine:

  1. (http://foo.com/a/b/c/, StrongWildcard)
  2. (http://foo.com/a/b/, Exact)
  3. (http://bar.com/, Exact)
  4. (http://foo.com/a/, WeakWildcard)

A request coming in for http://foo.com/a/b/c/d/ will match (1).

A request for http://foo.com/a/b/ will match (2) since the strong comparison fails (/a/b/c/ is not a prefix of /a/b/).

A request for http://foo.com/a/d/ will match (4). Even though “/” is a prefix match of “/a/d/” for (3), the hostnames differ and so the Exact match will fail.

Lastly, a request for http://bar.com/a/b/ will match (3). (2) is a prefix match but the hostnames differ, and (3) takes precedence over (4) in priority order.

Hopfully this helps demystify our endpoint URI matching process!

Café Crêpe (Seattle, WA)

Rating:

LL with dessertFor the past few Tuesdays Lauren and I have been taking a “Big Fat Jewish Wedding” class at UW Hillel. Our weekly tradition includes a pre-class meal in the U-District. Last week on our way to Caspian Grill we saw that a Café Crêpe had opened on the Ave. This is part the same mini-chain from Vancouver that have a number of branches around Robson St. I had enjoyed those in the past so tonight we stopped in before class.

Overall is was so-so. The service was friendly and quick, though there is zero ambiance in the place — just some empty white tables in a sterile undecorated room. We chose a spinach, mushroom, and emmenthal crêpe from the very small menu. The mushrooms were raw, the crêpe itself was too thick, the one saving grace was gooey melted emmenthal.

The dessert crêpe (strawberries and chocolate) was better, though again the crêpe was too thick. But it was strawberries and chocolate and so we polished it off 🙂

Café Crêpe would do in a pinch, but I’ll be continuing my search for a good Seattle “fast crêpe” (a la Crêpes A-Go-Go).

Café Crêpe
4508 University Way NE
Seattle, WA 98105

UPDATE: Café Crêpe has closed this location (seems I wasn’t the only one with a ho-hum experience)

Gorditos (Seattle, WA)

Rating:

Three things to know about Gorditos: Arguably the best burritos in Seattle, prices are cheap, and portions are HUGE. They are famous for the portion sizes: like grande burritos the size of a small child (if you go they have a picture to prove it).

I’ve heard about Gorditos for years from numerous friends, and they always get a dreamy look in their eyes as they talk about it. But I don’t find myself in Greenwood very often. Today however, it was finally meant to be. LL and I were going to meet DeAnn for lunch in the Greenwood area, and I suggested we try Gorditos. DeAnn’s been looking for good Mexican food ever since she moved to Seattle in August and had so far come up with nada.

Parking in the area is a little tight (there are maybe 5 spots outside dedicated to Gorditos, but we found a spot just a few blocks away). While waiting in line we got to preview the more popular orders. Most were various burritos ordered “wet” (with red sauce and melted cheese on top).

burritos larger than your forearmWe also were able to witness the two sizes of burritos. The “regular” is what is pictured here. Split three ways we barely managed to finish it off. The “grande” is about 1.6 times the size (only $1 more!) and can supply most people with 3-4 solid meals. We ordered a “regular wet chicken burrito fajita-style” from the friendly cashier. Fajita-style means that in addition to the black beans, salsa, rice, sour cream, and chicken they add grilled onions and bell peppers.

The chicken is seasoned well and grilled fresh, and you definitely should spring for the “wet” burrito — the sauce is a little spicey and filled with chipotle flavor. Definitely worth a trip to Greenwood.

The atmosphere is fairly standard burrito-joint decor, with loud music playing in the background. You’ll need to speak up or order yours to go. But I’ve been told that the grande burrito will not completely fit into a takeout container 🙂

Gorditos
213 North 85th St.
Seattle, WA 98103
206-706-9352
Wed-Mon 10:30am-9pm (Lunch and Dinner)

Creating a Service on "any free port"

By default, when creating a ServiceHost we require you to specify a base address (e.g. “http://kennyw.com/myService/”). This is because your clients needs to know where to send messages to. Sometimes you have a situation where you don’t need to know the exact address up front (let’s say you are using WS-Discovery or some other registry-based lookup). In that case, you want to indicate to the transport to “use any free port” (or “port 0” in sockets-speak). Fortunately, Indigo has this functionality baked into our addressing parameters.

To signal you want this behavior, set ServiceEndpoint.ListenUriMode to ListenUriMode.Unique (the default is ListenUriMode.Explicit). At build time this will propagate to BindingContext.ListenUriMode, which will then cause the Transport to “unique-ify” the ListenUriBaseAddress.

For exclusive TCP (where the process is directly listening on a socket) we will bind to a uniquely available port#. For shared TCP, Pipes, and HTTP we will append a GUID to the base address which will uniquely identify this endpoint.