One WCF Service for Rest and Binary

икони на светци

The sweet spot of the moment is standing in a WCF design that tries to stay with one service contract per tiny application (concern). The motivation to do this is for ease of web.config maintenance where there will be one service declaration in the collection of services in system.serviceModel.

The desire for one service definition leads (me) to learning how to build a service contract that supports binaryMessageEncoding and text-based “rest” WebGet or WebInvoke. This desire is reinforced by the following observations (seen in Visual Studio):

  • Adding a new WCF Service item for the first time auto-generates behaviors and serviceHostingEnvironment declarations in system.serviceModel. No service declaration is generated—which is makes the configuration more maintainable.
  • Adding a new AJAX-enable WCF Service item generates a service definition because it needs an explicit endpoint definition with an AJAX-friendly binding and behavior configuration.
  • Adding a new AJAX-enable WCF Service item after adding a WCF Service item causes the first WCF service to break—so the idea of trying to get MEX and rest by making a few Visual Studio moves with “smart” defaults (without Glenn Block’s help) is not realistic.

The System Service Model Service Definition

Here is that single service declaration promised earlier:

<services>
    <service name="Songhay.Web.HostRoot.Services.WcfServiceOne"
        behaviorConfiguration="mexServiceBehavior">
        <endpoint address="mex" binding="mexHttpBinding"
            contract="IMetadataExchange" />
        <endpoint address="" binding="customBinding"
            bindingConfiguration="customHttpBinding"
            contract="Songhay.Web.HostRoot.Services.IWcfServiceOne" />
        <endpoint address="json" behaviorConfiguration="ajaxBehavior"
            binding="webHttpBinding"
            contract="Songhay.Web.HostRoot.Services.IWcfServiceOne" />
    </service>
</services>

The customHttpBinding and ajaxBehavior most distinguish this little design. Respectively, we have:

<bindings>
    <customBinding>
        <binding name="customHttpBinding">
            <binaryMessageEncoding />
            <httpTransport />
        </binding>
    </customBinding>
</bindings>

and

<endpointBehaviors>
    <behavior name="ajaxBehavior">
        <enableWebScript />
        <webHttp helpEnabled="true"/>
    </behavior>
</endpointBehaviors>

Also, notice that the customBinding and webHttpBinding are not sharing the same path such that http://localhost/MyService.svc/ would be for binary transport and http://localhost/MyService.svc/json/ would be for the AJAX behavior.

Selected Resources

Today’s @elijahmanor links…


If memory serves...

Today’s @denisejacobs links…


AG test of a great grids system

You like the new look of kintespace.com?

Картини
Leaf /

Apart from yours truly, there are three sources to credit for anything you may like about the new look of kintespace.com:

  • The 960.gs Grid System
  • Tomoko Matsushita for suggesting that I use photographic backgrounds (actually I already had this idea but she helped to remind me). The background used, as of this writing, for the kintespace.com home page is from Japan, by the way, not Africa…
  • June Edmonds for finally having the time to lecture me at length about color (the last time we tried to get into something technical was in 2008!). This 2011 talk led directly to me using Adobe’s kuler.adobe.com with some semblance of technique.

My interpretations of June’s color talk…

June teaches me to look for these high-level concepts when approaching color:

  • Start with one ‘base’ color and then look for its compliment (using a tool like Adobe’s kuler.adobe.com).
  • Tint variations of the ‘base’ color means white has been added to the “pure” color.
  • Tone variations of the ‘base’ color means black has been added to the “pure” color.
  • Neutrals (grays) are not colors.

Back when I wrote “CSS Biggest-Box, Five-Color Strategy,” I was completely ignorant of this approach—so that stuff has to be abandoned for my ignorance.

My ‘sole’ contribution to the new design…

I don’t want to misrepresent others in case what follows sucks among the accepted pundits. I consciously used transparency effects to ‘replace’ the “need” rounded corners. My assertion is that right-angle corners in Web design are so “boring” and “old-fashioned” is because these hokey corners define solid fills—and it is actually the solid fills that are “boring” and “old-fashioned.” The cure for boring solid fills is transparency effects.

Here are some flippant statements about rounded corners:

My preference for transparency effects does not free me from the problems Web designers have with Microsoft Internet Explorer. I’m using the jQuery Color Plugin to get transparency effects—which is still in beta—and my guess is that this beta status is in part because of Internet Explorer. The relatively timid reaction my stackoverflow.com question, “IE9 ‘tearing’ background images behind scrolling blocks with background transparency,” suggests this to me.

New Things Learned in the Labor Camp

I am not known for understatement—don’t mistake my weird academic formalism (near word salad at times) as understatement. So, when I say that my last few weeks of employment is as close to a “dream job” (as eating lunch by the hour on the Amgen campus), “sure” one might say—“whatever.”

So let’s see how this “dream job” thing progresses (to something like dream quality-of-urban-life and dream debt-freedom). What I definitely possess are the following technical skills:

Shelving in TFS also prevents work from being overwritten…


Amgen Campus, Thousand Oaks

In “The IT Workplace: Doing it Basil Style” and “The Politics of Team Foundation Server (TFS),” I clearly reveal that my ignorance of the power of shelving in Team Foundation Server was strong with me. I should have read “What is Shelving in TFS? just a soft checkin so others can see code?”—which was, by the way, written in the winter of 2009. Here’s some news to me:

  • Shelving is a record (proof) that (incomplete) work was done for the day.
  • Shelving allows two (or more) developers to work on the same code files—such that the developers can reconcile their work via merging.
  • Shelving allows one developer to work on two (or more) future “change sets” pseudo simultaneously.

Using WCF to return JSON from a jQuery AJAX call…

So this “dream job” is not perfect: as I’m the dude who would prefer to work with Azure Table Storage and/or RIA Services, being asked to build an AJAX call from jQuery to a WCF service should be quite unpleasant for me. Instead, I now have something to talk about to an interviewer frozen in the .NET 3.5 timeframe asking me questions about WCF. Here are some related research links:

“Splitting” Web Configuration Files

In 2007, Nikhil Kothari writes, “[It’s] an odd feeling when you discover something in your own product, you didn’t quite knew existed! … [There’s] a little known attribute called configSource, that can be specified on a section which allows the definition of the section to live in another actual file.”

My usual self-critical thing would be to note the year 2007 and wonder why it took me so “long” to get the news—but I actually have a note about configSource from 2007. Clearly I’ve forgotten about it and this warning might have encouraged me:

Jon Rista warns, “The downfall of using the configSource attribute is that it requires all configuration settings to be placed in the external file. No inheritance or overriding is possible, which in some cases makes it useless. All external configuration files used with the configSource attribute must also reside in a relative child path to the main .config file. I believe this is in regards to security concerns with storing the file in a relative parent path in a web environment.”

Using SQL Query Profiler to See Stored Procedures with Decent Parameters

SQL Query Profiler is a performance tool—just like Fiddler is a performance tool. But like Fiddler, SQL Query Profiler tracks and displays the communication with a server. Click on a link and Fiddler will show you exactly what resources (images, documents, etc.) travelled “across the wire”; do the same while SQL Query Profiler is monitoring and you will know exactly which database objects are queried/executed.

Looking at a folder full of stored procedures on your first day of work can be very, very intimidating. Using SQL Query Profiler as a stored proc’ snooper can be quite an eye opener, bringing some stress relief.

Using JS Shell to Write Somewhat Involved jQuery DOM Manipulations

It’s too bad that JS Shell (jsshell) was made only for Google Chrome. Having spent three months of many, many 12-hour days with Chrome, I do not consider it a superior developer tool. Nevertheless, it has the only add-on that I find actually running JavaScript directly against the DOM in the same manner “real” JavaScript running from a file would. This interactive shell simulation allows me to seriously write JavaScript in an “Immediate Window” instead of writing to a file, saving that file and reloading the file in the browser.

A certain Telerik AJAX control needed some modification for my “dream job” (which is quite a tedious endeavor) and jsshell went a long way toward making the tedium short.