101 Free Tech Books Update – I Won A WCF 4 Print Book!



Five days ago I got a great email from 101 Free Tech Books. Seems the drawing I wrote about is real!!

Yes, I won a FREE print book. Filled in my shipping information yesterday and got the post that confirms my order was being processed. Feels so real! I’m even asked to give testimonials after receiving the book, which I will…

Which Book?


The book I have chosen is “Professional WCF 4: Windows Communication Foundation with .NET 4”. Sounded like a great title!

There is a trick in here. The option for books is only available from my wish list prior to the random drawing. I didn’t pay enough attention to this earlier, so, had a very small wish list of just “sample” books in it. Some of them I already had as ebooks. This was not very right.

I also tried to choose another book, add to my wish list, and go back to choosing again, but, as mentioned, only the books added prior to wining were there. Makes sense though!

You Can Win Too!

Now, I can recommend those people even more! They emphasize completely on showing how real this is, and I seem to believe them so far.

You can use my reference registration URL below and start adding people using your own URL so that maybe we both win more books!


There are 101 books to win EVERY MONTH.

Just remember, add as much as you can to your wish list now, and let the decision come later ;)

Good Luck :)

Videos from NDC 2009: SOLID Principles, Legacy Code, WCF, Software Design,…

Here’s another email from the internal mailing list of Injazat .NET Ninjas (Ninjazat, AKA  as we call ourselves), that I’m sharing with blog readers as well.

Just a place holder, until I move one of my 18 (just discovered the number now – terrifying!) drafts in my Windows Live Writer into a published post, or delete them all!

Subject: [Learning] Some very interesting videos

Some videos from NDC 2009 event (Norwegian Developers Conference 2009) – about software design and related issues:

· NDC Video – Robert Martin – S.O.L.I.D Principles of OO class design

· NDC Video – Robert Martin – Craftsmanship and Ethics

· NDC Video – Robert Martin – Component Principles

· NDC Video – Robert Martin – Clean Code III – Functions

· NDC Video – Michael Feathers – Working Effectively with Legacy Code

· NDC Video – Jeremy D. Miller – Convention Over Configuration

· NDC Video – Michael Feathers – Seven Blind Alleys in Software Design

· NDC Video – Ted Neward – WCF Patterns

· NDC Video: Michael Feathers – Design Sense

For the complete list of videos from this event check videos from:

· Day 1

· Day 2

· Day 3

My favorite topics are (recommendations):

· NDC Video – Robert Martin – S.O.L.I.D Principles of OO class design

· NDC Video – Michael Feathers – Working Effectively with Legacy Code

Of course the other topics are interesting as well.



[Link List] jQuery, Agile, WCF REST, WF, OpenXML, Live Messenger Anniversary, Wallpapers

Yet another internal .NET Team email in my current company, Injazat Data Systems, that I sent yesterday, and am sharing with you as well.


· Simplify calling ASP.NET AJAX services from jQuery

· Use jQuery and ASP.NET AJAX to build a client side Repeater

· Reordering invoice lines using jqGrid and TableDND extension

· LA.NET jQuery Posts/Articles


· Implementing Scrum


· Web Development With ASP.NET Learning Material (Course – Source: MSDN Ramp up Learning Program)

· ASP.NET Articles on CodeGain (Many Articles)


· Posting Twitter Tweets from ASP.NET using the WCF REST Starter Kit Preview 2


· Migration Guidance for the WF Developer

o Part 1

o Part 2

Office Open XML

· Embedding Any File Type, Like PDF, in an Open XML File


· YoutTube: Windows Live Messenger 10th Anniversary Celebration Video

· 99 Amazing Widescreen Wallpapers To Spice Up Your Desktop

As usual, those and others are all originally shared on my Google Reader Shared Items:



Happy weekend,


[Link List] Recent (and non recent) Articles on Various Topics

Allow me to quote here some emails I sent to the the Dot NET developers group in my company, Injazat, or, as we call ourselves, Ninjazat. I thought it’ll be useful to share some with you as well.

·         ASP.NET MVC – 20 Hours of FREE Video Tutorials

·         LINQ FAQ

o   LINQ FAQ for Newbie’s

o   LINQ FAQ Part 2

·         How we handle application configuration

·         ScottGu ASPNETMVC Session Video Available Now (Part 1/2 & 2/2)

·         Web Validation: Best Practices and Tutorials

·         Building a Single Sign On Provider Using ASPNET and WCF

o   Part 1

o   Part 2

o   Part 3

·         NxtGenUG Cambridge: Creating extendable applications using MEF slides and code

·         Dynamic Languages and .NET – Developer Day Scotland slides and code samples

·         patterns & practices: Data Access Guidance (VS 2010 Stuff)

·         Refactoring challenge

o   Part 1 – Examination

o   Part 2 – Preparation

·         LINQ is not LINQ To SQL

·         Visual Studio Programmer Themes Gallery

·         Connecting to Mailbox on Gmail and Fetching List of Emails using POP3 and ASP.NET

·         Optimize your page for UpdatePanel

·         CMS in the .NET World

·         Getting jQuery Goodness into ASP.NET AJAX – Take II

·         What to do when SELECT query is Running Slowly?


As usual most of them coming from my Google Reader Shared Items http://www.google.com/reader/shared/08221036579558509505

Previous Email:

ASP.NET AJAX Control Toolkit ModalPopupExtender Control in Action


Previous Email:

[jQuery] Animate Image Filling Up Using jQuery

Make Sure To See The Demo First:


See the article then:



Have Fun!


Easy way to quickly test WCF services hosted with HTTP binding

I found this great article that tells you how to do testing for WCF services exposed as web services, especially REST services (like the ones we create in my company for the project I work on now).

What’s the problem ?

Typically, for HTTP GET services, you can just put a URL that matches the URI template of the service (the template of the URLs that call the service) in the browser, and simply see what comes back in the browser itself

However, when you want to test a service with other HTTP verbs than GET (Say POST, PUT), you need a console that creates the HTTP request with headers and request body and such, because a browser normally has no way of making you create a new customized request (because it creates them for you and encapsulates the entire process of request/response).

Usually you write that console on your own. We wrote one for the current project but it didn’t serve all our needs.

The solution

There’s a program called “Fiddler” (Microsoft Freeware). This program works as proxy server that allows you to intercept and inspect requests and responses for all the web calls you do from your machine. This is very useful but as Firefox extensions do this for us, I haven’t personally installed it for a while.

However, Fiddler has a great feature called “Request Builder”. This is where you can construct your request with all parameters and such and change any part of it (headers, body, raw request) and see the response in multiple views (Raw, Text XML, …).

You can put the URL of your service in it, choose (or type) the HTTP verb and HTTP protocol version (by default 1.1) it uses, and then check the result to see whether it is what you expect or what.

Notes on usage

  • With Vista or IPv6 supported OS, this fails sometimes especially when your service is hosted with ASP.NET development server (that’s included in Visual Studio). To fix that in Fiddler, go to Tools->Fiddler Options and then uncheck “Enable IPv6 (If available)”.
  • This is how Fiddler looks like in sample test
    Note that:
  • The part to the left is the previous HTTP connections. You can fill the request builder parameter by dragging any of them.
  • The “Content-Length” header is filled with the right value automatically for you by Fiddler itself.
  • An important part to enter in your requests is the “Content-Type”. Many services would behave differently according to that. For an XML web service, that’s typically a new line with “Content-Type: application/xml” in it.
  • Fiddler configures itself as proxy for IE automatically. Firefox by default does not use a proxy server. To make Firefox it use Fiddler, from Firefox go to Tools->Options, then the “Advanced” tab, then “Network” sub-tab, then in the part “Connection” click “Settings”. Then
    • Click “Manual proxy configuration”
    • Enter in “HTTP Proxy” (and “SSL Proxy” if you want this for HTTPS) and then “8888” (default port for fiddler, can be changed from it) in the “Port”.
    • Clear the “No Proxy for” textbox to be able to test URLs on “localhost”.
      You can alternatively keep it and use http://MachineName instead of http://localhost when testing.

    The One Resource for This

    This is coming from a great article that talks about the topic (but not with all the notes). The article also shows a VERY NICE example of creating a REST web services WCF project to be hosted in IIS.

    Go read it right away.

    Link List 20080617

    · Everything You Wanted To Know About MVC and MVP But Were Afraid To Ask

    · Functional Programming in C# 3.0: How Map/Reduce/Filter can Rock your World

    · MbUnit 2.4 – Avoiding Crappy Data Resulted From The Test

    · Managed Extensibility Framework

    · IronRuby at Tech Ed 2008

    · Velocity: A Distributed In-Memory Cache from Microsoft

    · Must See WF/WCF Influencer MSDN Webcasts

    · WCF Webcast Series (Old but good)

    · Using CSS to Fix Anything: 20+ Common Bugs and Fixes (Found by Mohamed Tayseer)

    · A jQuery Client Status Bar

    · jQuery for Asp.net MVC preview 3

    · Hands on Labs for Web Client and Smart Client (Web Client Software Factory, Smart Client Software Factory)

    · Code Style Review Using Microsoft Source Analysis

    · Did you know… You can use Tracepoints to log “printf” or “console.writeline” info without editing your code? – #237

    · SOA: Making The Paradigm Shift Part 9 of N

    · Functional C# – Learn from F# and LINQ

    Enterprise Service Bus Messaging Using nServiceBus

    I have been working lately with a big group of fellow developers here in SilverKey on the architecture and design of a relatively big project that required much services and messaging work. We thought that we should implement our public services the REST way using WCF for .NET 3.5, with so many customizations, and that we’ll use a library called nServiceBus for internal messaging. Mohammed Nour wrote a little about thinking in REST.

    nServiceBus is a framework for handling publisher/subscriber (pub/sub) model of messaging. It provides reliable messaging via the Enterprise Service Bus (ESB) pattern, and uses MSMQ as the physical bus.

    It’s an interesting piece of work to look at actually; of course free, open source. I have been involved in evaluating it for our project, and wrote a document about it as part of my work, so that it’s easier for the rest of the team to use it later. As the documentation for nServiceBus is very limited at this stage of the project, I and my boss Dody decided to share the document with the community.

    Another very important reason for this is enabling the nServiceBus group to correct and enhance the document as much as possible. That’s why the document is published under the Creative Commons Attribution-Share Alike 3.0 Unported License.

    Download the document

    WARNING: This IS going to change, see the nServiceBus Yahoo group for updates to this document.

    If you are lazy to download check this out:

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

    Revision History

    Author: Mohammad Meligy

    Revision Number: 1.1


    Status: Public Draft

    Last Updated:

    Feature ID:

    Related Document(s):



    Revision History    2

    Overview    4

    Context    4

    Glossary    4

    Requirements    5

    Goals    5

    Non Goals    5

    Major Features    5

    Dependencies    5

    Usage    6

    How it works    6

    Defining the message contracts    6

    Writing the code to handle the messages    6

    Setting up messaging communication    7

    Logging (Optional)    12

    Security Consideration    12

    Security Constraints    12

    FAQ    13




    This document shows the use of nServiceBus library (www.nservicebus.com) for managing enterprise messaging using the service bus pattern. The model explained is an advancement of a publisher / subscriber model.


    The document is written to be guidance for developers involved in intercommunication between components in enterprise project, however, it is written with no specific relevance to the project components, and can be used for any project that implements this kind of messaging.


    There’re some common terms used in this document:

    • Message

      A message is the object that groups the data you want to pass from a module to another module or system for processing outside your module.

    • Publisher

      This is the code that creates the message and puts it publicly to be available for later processing.

      Note: It’s very common when dealing with nServiceBus to call the publisher as a "Client"

    • Subscriber

      This is the code that checks for published messages and passes is responsible for performing any desired operations on them.

      Note that the subscriber that subscribes to a certain request message for example may want to send a response message in return, hence, it then acts as a publisher, and so. It’s normal that the module that acts as a publisher acts also as a subscriber and vice-versa.

      Note: It’s very common when dealing with nServiceBus to call the subscriber as a "Server"

    • Service Bus

      This is the shared message store where all the messages are be written to by the publishers requesting processing, and then later read by the subscribers for processing. Once the messages are delivered to subscribers, they’re typically removed from the message store.




    1. Enable asynchronous messaging across multiple servers.
    2. Ensure reliability for the asynchronous messaging.
    3. Enable a publisher / subscriber model for the messaging.
    4. Enable multiple subscribers to each published message.
    5. Enable a publisher to receive response messages from subscribers.

    Non Goals

    1. Enable canceling of already published messages.
    2. Specify the sequence of message subscribers handling via configuration (still available from inside the subscriber code).

    Major Features

    1. Setting a server to act as service bus for multiple publishers/subscribers.
    2. Setting the publishers to send messaging to a service bus asynchronously.
    3. Setting multiple subscribers inside a service bus.
    4. Limiting the handling of messages based on their type.


    1. MSMQ – Acts as store for published messages
    2. Spring.NET Library (On all the publisher and subscriber application – included with nServiceBus assemblies) – For initializing the messaging infrastructure
    3. Log4net Library (http://logging.apache.org/log4net) – For logging purposes
    4. Serialization (On all the code classes that are included in published / returned messages)




    How it works

    You create the message type, create a type that holds the processing of the message (called message handler), configure the publisher and create the message instance itself that it publishes to the bus, and, configure the subscriber to subscribe to the bus and map the message instance to new message handler instance.

    You’ll notice that the difference between the client and the server is really small. A client publishes a message to one or more primary buses. The server subscribes to the messages it has handlers for that come on the primary bus. But, for the server to be able to send back "response" messages to the client, the client also has its own bus (queue) that it subscribes to for handling response messages.


    Defining the message contracts

    You define the message type (class) normally in any VS project with certain considerations:

    1. It should implements an interface "NServiceBus.IMessage".

      This interface does not require you to implement any methods / properties.

    2. It should be attributed as "Serializable".
    3. It’s highly recommended that your message have an identity field of type GUID.


    This message acts as data contract between the publisher and subscriber, and it should be available to both. This is the actual data that’s being passed between them.



    Writing the code to handle the messages

    A handler is the business logic that does the actual processing of a message. When the subscriber receives a message, it checks which handler(s) it should call to process this message. A handler is independent from the subscriber and can be used with multiple subscribers though.

    When creating the handler type (class), you should either

    • implement the interface "NServiceBus.IMessageHandler<MESSAGE_TYPE>"
    • Inherit from class "NServiceBus.BaseMessageHandler<MESSAGE_TYPE>"

    MESSAGE_TYPE is the type of the message to handle.

    The two options are equal in effect. You write a method "public void Handle(MESSAGE_TYPE)" where you write the code that actually processes the message.

    Note: You can implement the interface multiple times for MESSAGE_TYPE_1, MESSAGE_TYPE_2, etc, and then you have to implement the methods "public void Handle(MESSAGE_TYPE_1)" and "public void Handle(MESSAGE_TYPE_2)", etc.


    In this example, the handler just creates a message of a different type (which it does not have to do or have to define) and sends it to the service buss.

    The last line has the method "Reply" which accepts "paramas" of message(s) that act as response to the original message and sends the response message(s) back to the queue of the client (who sent the original request message).

    Error Codes

    To indicate that there was an error processing the message. NServiceBus promotes error codes and creating custom messages that represent the error against throwing an exception.

    Here’s a sample code or creating "enum" for wrapping error codes and returning it:


    Setting up messaging communication

    Now, you have a message type, and a message handler. What’s remaining is writing the publisher that sends this message to the service bus, and the subscriber that asks the service bus to subscribe to any message of the type(s) you want, and before all that, creating the service bus itself.


    Preparing the service bus

    The first thing you need to do is to create the MSMQ queue that acts as a service bus. The name of the queue will later be available to publishers and subscribers to write messages to / read messages from.


    Creating the publisher

    The publisher is the code that sends the messages to the service bus through configurations. Before writing anything, you need to add references to the following assemblies:

    1. NServiceBus
    2. NServiceBus.UniCast
    3. NServiceBus.UniCast.Subscriptions
    4. NServiceBus.UniCast.Subscriptions.Msmq
    5. NServiceBus.UniCast.Transport
    6. NServiceBus.UniCast.Transport.Msmq
    7. utils

    The way nServiceBus highly promotes is setting the publisher configuration in the app.config/web.config of the Visual Studio project that contains publishing code using Spring.Net configuration.

    A typical configuration looks like this:

    1. A configuration section that registers the Spring.Net configurations

      The "Common" and "log4net" parts are optional and are only used in case you want to use logging.

    2. Create the standard sections for Spring.NET

    3. Replace the part "<!– All the required configuration for nServiceBus comes here –>" with the actual configuration to use. A typical configuration looks like:

      The properties that matter in this context are:

    • "Transport"
      • "InputQueue"

        Sets the path to the queue where the messages will be read from. This is essential as the publisher might also subscribe to messages (typically responses to published requests).

        Note: For MSMQ v3 (Windows XP, 2003), this must be a local queue.

    • "Message Owners"

      This connects the message – based on the message type (class, the one that implements "IMessage" interface) – to the MSMQ address where it will be published.

      As shown above, this is written as a dictionary, where:

      • "key": is either the name of the message type (class) – or – the name of an assembly, so that nServiceBus looks inside this assembly and locate all the classes that implement the "IMessage" interface.
      • "value": is name of the MSMQ queue to publish the "key" messages to
    1. Write the actual code that sends the message to the service bus

      In this sample, "RequestDataMessage" is just the message type (class).

      The code is pretty simple, you:

    • Use Spring.NET to create the service buss
    • Create the message itself normally and fill its members
    • Send the message to be published to the bus (This has some alternatives discussed later)
    1. As the message is published asynchronously, you can optionally create a callback method that handles the message. A code for something like that would look like:

      You send the message and sending returns an "ICallback" object. This object has single method "Register" which you use to register "AsyncCallback" delegate to a method that will be called asynchronously when the sever returns a reply, which is "RequestDataComplete" in our example. A sample implementation of this method would look like:

      Clearly, you can see that result returned is a "NServiceBus.CompletionResult" which has both "state" which has the original sent message, and "messages" which has the response messages.


    Creating the subscriber

    The subscriber is the code that reads the messages published to the service bus, and pass the messages to the messages handler(s) set for it.

    The configuration for the subscriber is very similar to the publisher:

    1. Steps 1 to 3 in the publisher are the same for the subscriber
    2. The final nServiceBus specific configurations would look like:

      Note the following sections as well:

    • "Transport"
      • "InputQueue"

        This is the MSMQ queue that the subscriber will listen to.

    • "SubscriptionStorage"
      • "Queue"

        This is the MSMQ queue where the subscription messages will be stored (The mapping between the subscriber and publishers)

        Note: For MSMQ v3 (Windows XP, 2003), this must be a local queue.

    • "MessageHandlerAssemblies"

      This is a list of assemblies to look in for message handler types (classes, ones that implement "NServiceBus.IMessageHandler<MESSAGE_TYPE>"), so that it maps the handlers to the messages it receives

    1. Writing the actual code that subscribes to the bus. This is very simple piece of code

      You can see it’s very simple. You create the "Bus" object from the information in the config file using the "Spring" library, and just start the bus. It loads all the necessary information like which messages to subscribe to and the mapping between message types and message handlers, etc, from the config.

    2. Now you need to deploy the code that runs the server. Note that the bus should be living forever! You’ll want to treat it as you treat a Windows Workflow Foundation Workflow Runtime for example. Either make it an independent Windows Service, or write it in some Application even of the global.asax of a web application.


    Logging (Optional)

    For the error logging and such, nServiceBus library has dependency on another library called Log4net. You can use that for any kind of logging. Sample logging code looks like:

    For Log4net library specific documentation check


    Security Consideration

    Seeing how nServiceBus works, you notice you have typically two queues, one for the server and another for the client. You also notice that you have two operations for each, read and write.

    Security Constraints

    To setup MSMQ, you can use public queues, but those are hard to create and are very insecure. Typically you use the default private queues. This causes few constraints on the queue operations.

    • For reading from the queue (AKA subscribing to the bus), the queue has to be on the same machine as the subscriber. You cannot subscribe to a queue that is on a different machine if you are using MSMQ version 3 (like using Windows 2003).
    • To write to the queue (AKA, publish to the bus), the OS process running client/publisher has to be running with a use account that has sufficient privileges on the machine that has the queue you want to write to. This means you’ll typically be running the client and server on two machines in the same LAN with Active directory and sufficient user access, which is a common scenario anyway.


    1. Where to find a copy of the examples in this document or get a working example for nServiceBus in general?

      The code snippets in this document are mostly coming from the "FullDuplex" example that comes with the library source code.

      The source code can be found at: http://sourceforge.net/projects/nservicebus

      For more examples, check the library Yahoo group at: http://tech.groups.yahoo.com/group/nservicebus

    2. When I downloaded the nServiceBus source from the library SVN repository I found the configuration much different than described in this document. Any Idea?

      The next version of nServiceBus will have different configuration. It’s not documented here because it’s NOT a complete release yet so is still subject to change before the next release.

      For differences between the configuration of the current release and the upcoming release, check nServiceBus wiki page at: http://nservicebus.wiki.sourceforge.net/Configuration

      There’s also incomplete documentation of the examples on nServiceBus wiki at http://nservicebus.wiki.sourceforge.net/Samples

    3. Is there any documentation for nServiceBus?

      There are few resources:

    However, most of those are either very limited or incomplete.

    1. How do I write the name of a MSMQ queue that exists on a different computer?

      You write the name of the queue in a format like "QUEUE_NAME @MACHINE_NAME"

      MACHINE_NAME is the computer name of the machine that has the queue.
      QUEUE_NAME is the name of the queue itself


    Link List: SOA / Architecture + Bonuses

    This is the email I sent to SilverKey Tech. Egypt dev team yesterday, sharing here as usual.

    Bonuses (AKA, unrelated links – definition)

    About dotNETwork Usergroup 2nd Gathering -Or- WCF Messaging, SQL Server 2008 Manageability

    Today was .NETwork usergroup second gathering. The usergroup is the first and only large/effective "offline" usergroup in Egypt (although there’re many others in INETA). They had a great success in their first gathering when they brought Steven Forte to talk about SQL Server 2008 new features for developers and ASP.NET MVC design pattern. I had a detailed post about it in my GWB blog at that time. Check it out for details.

    Background: First To Second Gathering (Warning: Boring Part!!)

    The .NETwork gatherings so far are more like small independent events. We -SilverKey Tech- were the first to start such events with our full day event, DemoDay (See GWB posts on DemoDay I, DemoDay II ), and later ITWorx had their CuttingEdge Club (See GWB post); which were both great corporation contribution to the developer community (and I believe we need more guys to start doing similar events), but, didn’t have much of "offline user group" nature between each round of either events (although almost each of us is friend to the other or at least friend of a friend!!). While .NETwork preferred the same "event" model, they had online and offline communication between the users of the usergroup (although mainly between students and organizers so far, but it’s a step anyway). It’s very interesting what Mahmoud Ghozz (one of the organizers) told me that the 2nd gathering session topics/speakers setup was done mainly through just phone calls!

    So, in the 1st gathering, they were very successful getting all support from Microsoft Egypt, who held the meeting in their building and provided deserts as cool treat, LOL! They also used corporate contacts of the organizers to get Steven Forte (a frequent MDC speaker) to deliver the sessions. That was more than great but it was hard to keep. I think there were two main issues there: the fact that the gatherings need a determined location that can be available for "frequent" gatherings, and the other fact that to comply with the event model and also for the sake of hosting more events, the speakers need to be "local", from Egypt. The two goals were so clear as Remon (the main organizer) announced them in the 1st gathering, and were nicely achieved in the 2nd one.

    The idea was simply simply getting the location from a private university. Sure any university would welcome that! They chose the Canadian University in Egypt, which was (like all private universities) quite far from Cairo that it still required buses to get the attendees (Not sure whether the university or Microsoft Egypt – who also brought free food I heard :D – provided the buses), and got an Egyptian MVP and Egyptian Microsoft Redmond Employee to deliver the sessions. That was a great step in stability that I heard some intentions that the gathering is going to be in the same location every 3rd Saturday of every month. Great news to here :).

    So, as you see, it’s insightful great advance, and I really like that to the extend of getting you too bored before starting walking through the sessions, so, let’s start!

    Session 1: WCF – Messaging & Channel Model (By Khaled Hnidk)

    Khaled is a BizTalk MVP, and when he talks, you can see clearly that he just knows pretty much what he’s talking about, which used to be a little bit missing from certain speakers in events I attended during the last few years (but is increasing nowadays thanks God). It’s interesting how he went slowly during the session, but still delivered one of the deepest sessions I have attended in the topic (and I have attended many!). What helped this is that he was wrongly thinking or informed that the session time was 2 hours not 1.5, so, he a lot to say, and those who know the sessions I deliver or attend know how much I LOVE that ;).

    As most of the attendees were students (I may talk about it more thoroughly after covering the sessions), he started the talk with regard to Webservices, why they exist at all, and the webservice (ASMX) model. When a client want to send a message to the service, it needs to serializes the message, send it through a transport layer (client proxy), get to the service transport layer, which de-serializes the message in order to process it. He discussed the idea of dispatching (directing requests to service method calls) in that model through WebMethod attributes. After processing, the service response is sent back to the client through the same steps, but in opposite direction.

    Then he went into webservice model limitations. You know, in terms of method of communication and static host, requiring HTTP method (and hence HTTP server) to work, and also having to define security through attributes making the security code that’s part of the message header something you care about when writing the service itself, and have to maintain along with it (although it’s not part of the service logic). Added to that the limitation of the message itself, for example, as the message size would be dependant on server general web settings, and you have no built-in way to define metadata of the service (i.e., how about a sequence required for message calls?). He mentioned how WS-* standards have come to sort of try to work around such limitations, which required Microsoft to release Webservice Extensions (WSE) to support those in its ASMX implementation.

    Well, as you may think, that was a where the talk of WCF started and took place. Khaled reminded the audience that now we have multiple ways of communication. On .NET, there’s COM+, Remoting, Webservices (ASMX) – hey, with and/or without WSE -, which are too much. Of course other platform vendors have their own stack of tools/standards as well (like the stuff coming from IBM). Yes, of course. That’s what WCF came to unify and improve its model from the .NET developer side. Before going further, Khaled approached Microsoft’s decision on hiring Don Box, the father of SOAP, and having him to work on creating WCF.

    Getting into WCF ABC (Address, Binding, Contract), Khaled stated how a message in WCF can be hosted in any application, event a simple console, and the host needs to have an endpoint "Address" to be called through. Getting the client to know "how" to call the service (i.e., whether it requires SSL, what max. amount of data can be sent at a time, etc) is the "Binding". Now what to expect from the service or what the service "can do for you" is the contract. Being recently married, he compared the model to what you do when you get a worker to do some painting or such for your house. To arrange the deal, the worker would example give you his mobile phone number (hey, "Address"). He would tell you "You can call me from … to …" (That’s "Binding"), he will agree with you to deliver a certain service -let’s say painting- (Which is a "Contract"). Khaled noted that almost the same concepts apply to the client.

    Still talking about ABC (invested by Clemens, on a side note from Khaled), he showed a figure of the message lifecycle, and focused on the messaging communication:

    • Request / Response (Each client request has a service response on the same wire)
    • One way (A message will be sent and that’s it)
    • Duplex (After a request, there’ll be a response, not in the same time frame, not even using the same address/binding).

    He used a funny example of that, slapping! If you slap someone in the room and he slaps you back, that’s "Request/Response". If he just does nothing, that’s "One Way" communication. If he leave you right away, just to wait you (or get someone) to slap you in the street, that’s a "Duplex" communication!!

    Going through addressing scenarios and special talk about the transport layer, Khaled had more to say about Duplex Communication. You know, you need to host the service, define ABC of the endpoint. The client is a bit similar, after all, the client has a service that has an endpoint, but this one complies to what what the service that the client requests does define.

    Using the same demonstration of ABC and message lifecycle, Khaled went into talking about "Binding". He described the lifecycle as the channel model stack. Below in the stack you have the transport layer (Last), then upwards comes the message encoder (that’s the serializer), and then you have more layers of your choice in the middle, typically the security layer, and then the dispatcher at the top of the stack (First).

    Talking about security, he noted that you may want to use symmetric session key (one key for communication during a session), that for example would require the security layer to send additional message (other than the message you are sending itself) to set that key first for the client and then later will use that key to encrypt your message when sending it. That brought up a new topic, "In Band" and "Out Of Band" messages. This concept is important for those who do work on extending WCF features. Simply "In Band" messages are the messages that your service code deals with and has to worry about- in short, knows about! "Out of Band" messages on the other hand are ones your service will not ever know about, like that key message mentioned before, and like the messages of WS-MessageDelivery Large Message Exchange (WS protocol that defines splitting of large message into smaller ones and combining them as one message back). Knowing the difference between both -Khaled reminds- is a necessity for those doing security extensions for WCF.

    Still with binding, we went into "Behaviors", as the name implies, this means changing (overriding) the way WCF works. To explain that, we started digging into demos.  The first demo was walking through a pre-created solution (Khaled recommended to have a separate VS Project for each service host, and a separate VS Solution for the service – that’s another VS Solution for the service client). He walked through the defined contract (that’s an interface that the service class implements), and related attributes. Serializing the non-primitive .NET types (say classes) involved in the service and using DataMember on the members needed for the service to operate properly. He noted that out of band messaging like security will be configured in the binding not the service code. He then moved to the service host, showing the snippet to tell the host which service is should host at all :). The host app.config file (which he calls -for fun- app."ounfid", that’s "Hedgehog" in Arabic!) has the binding. He showed how that’s defined using the service class name, and showed different endpoints demonstrating that each endpoint has its own ABC, showing the binding models that come with WCF out-of-the-box (answering a side question, he stated the binding can be defined in code as well).

    The next topic in the same context was meta data exchange, defining different channel model than standard. Yes, that’s where the behaviors come to play. The behavior is defined either for a service, endpoint, or operation (Method). He showed how you can for example inherit one of the built-in service behaviors and override its main processing models. An interesting point he showed was using HTTPWS binding on the host (meaning the host will provide the service over HTTP with WS standards), and while just defining HTTPWS binding on the host was enough, Creating a reference from the client application to the service showed that the client had each detail (instruction) it needs of that binding stated in its app.config, that’s like whether there’s quota for message size. That’s "right" because, that client might have been for example a JAVA application that knows nothing about binding and needs these instructions. The last part of the session was tracing the states of the client calling a service, proxy creation, opening and closing the connection to the service.

    The next demo started by iterating over dispatchers collection. that’s a dispatcher on each endpoint for direction to class methods, plus an additional undocumented zombie dispatcher that you read about only in blogs, Khaled mentioned. He noted that he "saw very few developers that needed to override dispatchers versos other WCF stuff"

    Now we started talking about service instances (creating service object that has the methods to call from the service class) by mentioning state management as the enemy (for the expensive memory it requires), Khaled reminded everybody of having a service instance per message. It was a good time to mention the 4 tenets of SOA (Service Oriented Architecture):

    (Note: I merged the original terminology with Khaled’s explanation)

    • Boundaries are explicit: Or service isolation (Each service is a separate contract)
    • Services Are Autonomous (You cannot deploy a service partially, or to clarify: each service should be able to perform regardless of any other service availability or so)
    • Services Share Schema And Contract, NOT The Class (You shouldn’t need an assembly to use the service, just the schema, like WSDL for example)
    • Service Computability Is Based On Policy

    Back to overriding service behaviors, Khaled demoed different service instance creation modes (when a new instance of the service is created). that’s Per-Call (every service request), Per-Session (every new client session), and Single (just one instance for all client calls, which is not good for memory performance). He showed us the number of service instances created in each mode for a client connection with 2 service operation (method) calls, and one more connection with single operation making every service instance response a GUID field he added to the service class.

    The next topic was "channel factory", he briefly mentioned you create a factory for overriding channel by code, that’s meaningful when the biding is variable in runtime. Speaking of binding and endpoints, I wanted to know his recommendation on hosting services in console-like applications like windows services, etc versos in IIS, He seemed to agree with me that IIS is the practical option, and added a note on the in-the-box power of IIS 6 application pools. He also added that Windows 2008 has another practical option, which is WAS (Windows Activation Services).

    The next topic was WCF tracing. Khaled demoed setting up tracing configuration like tracing sources for tracing each message/activity, adding tracing listener to a text file, and opening the trace file using Windows SDK 6 SVCTraceViewer tool, going through the log entries for mapping to service model (like initializing the service host, etc), and showing tracing entries mapping to the transport layer. He gave everybody an few advices. To go home and play with the SVC Viewer tool if they want to learn, and to remember that tracing the host (mainly IIS) would be through Windows Event Viewer, while tracing the service behavior itself would be through that SVC viewer tool.

    After a side question about encrypting part of the message not the whole message (which would be for certain business processes) that he recommended instead of having single service, splitting the services and having a central workflow as main service that splits the message and directs it to the right services; he went on a detailed demo for overriding Endpoint behavior. You get a method for applying client behavior (if the behavior is on the client endpoint, if not, just throw a meaningful exception there!), and another to apply the behavior on the service, which he used for a dispatch behavior for the WCF Message Inspection WCF Patterns (inspecting parts of the message and request parameter filtering). You access the message after receiving the request (that’s before executing the service code) and before sending response (yes, that’s after executing service code). Note that a message is immutable (that means you cannot change it). You normally take the message (passed to you by ref), put it in a buffer, do whatever you need to with the message buffer, and use it to create a new message that you replace the original message with. The last step needed after writing the behavior is adding it to the config.

    Here was the end of the demos. The rest of the slides and demos were cut due to discovering that half hour difference I mentioned above. The next part Khaled added after asking someone in Microsoft if she believes Microsoft would love to deliver certain messages to his audience. He stated that at the very beginning, but I thought it would be more appropriate for me to bypass it until we reach the part he started telling these messages, and here it came!

    The first talk was about BizTalk 2006 R2 WCF LOB (Line Of Business) Adapter SDK . A framework for with legacy code. You create the meta data in band stuff), inherit some classes and implement certain interfaces, which after you’re done can be used as yet other WCF channels than you can be bound to. It has tools that help generate you all you need to start (Overview). He also mentioned the SDK adapter pack which is contains adapters for SAP, Siebel and Oracle, etc. The last words were about "Project Oslo", which is a set of process/workflow modeling tools that aim to be the actual runtime of the code, not just a code generator like WF designer model. He said it’s said to be released with first quarter of 2009, and it’s work in progress with regard to Emacs-like editor.

    As a whole it was a great session. although many things had to be simplified for the majority attendance of students, and, that misunderstanding of time thing made us go very slow  in the beginning, and then have to skip parts at the end. Still, the guy is pretty knowledgeable and I now that next time he presents, I’ll likely be there.

    Session 2: SQL Server Manageability (By Mohamed Meshref)

    I used to know Meshref in ArabTeam2000 forum (a short while after he was accepted to join Microsoft SQL Server Team in the U.S.) and later MiddleeastDevelopers yahoo group. He is know for having a special way in talking about stuff, especially when it comes to talking about Microsoft (and it always does of course). Unfortunately, the guys was kind of sick yesterday (Oh, it’s already yesterday!), and it was hard for him to do the talking, however he managed to deliver a light interactive session with good demos still :).

    At the beginning, Meshref went talking about Resource Governor, it was mentioned by Steven in the first gathering (which I wrote about), but, I think it’s an essential feature (Many guys were "not" of the 1st gathering attendees still, and it didn’t take much for the talking).

    The next features he talked about were all built with regard SMO (SQL Server Management Object), that’s a library that has representation of all SQL Server Objects that enable doing something like another SQL Server Management Studio theoretically possible (Just kidding – let’s say a way to reach many parts of SQL Server Management Studio features by code). That’s very logical building in my opinion and I like the fact that Meshref and the other SQL Server did stick to it.

    The biggest feature Meshref talked about was Declarative Management Framework. This is basically a policy management framework. It allows you to define a certain policy on any object available within SMO (You do it normally through the familiar management studio), like setting a certain naming convention for all tables in the DB for example, and the policy can be applied to all DBs in the server, and/or exported to other server(s). Meshref went on demoing the creation of a new policy, showing that a policy can consist of more than one condition (and each condition can be reusable in other policies – think of it as Many-to-Many relationship). He showed how the policy does prevent violating it when enabled, and then went back to show us how we can set a description for the policy to appear to the user trying to violate it.

    Afterwards, he showed how we can "evaluate" our policy. That means seeing which objects do not comply with the policy (for example, objects created before the policy was created and and set active). At this point, Meshref mentioned the difference between the two types of conditions:

    • Deterministic: Those are the fixed rules, similar to setting a certain property of an object to always have a certain static value. The cool thing about such conditions, Meshref demoed, is that when you are using it, and checking what objects do not comply to your policy, you just click a single button to make SQL Server apply the policy for you on all the non-complaint objects or only one of them.
    • Non-deterministic: Those are the dynamic conditions well, the conditions in all are a bit limited to say "dynamic"!), En example to that is defining that all your table names should be "like ‘tbl_*’". Such condition cannot be applied automatically. You click the same button, but to apply it yourself this time.

    By the way, I asked Meshref whether there’re performance worries when using large number of policies (yeah, I was thinking of managed stored procedures), and he said that they tested them over huge number of policies (I think those were 15,000!!!), and I shouldn’t worry.

    Before going to the next demo, Meshref highlighted that the DMF is a SQL Server Engine feature, not a feature of SQL client or so. It makes sense and was important for feature after the demo. The demo was setting different policy modes for when the policy will be evaluated:

    • On Demand: Policy evaluated only when you go evaluate it yourself.
    • Schedule :Using SQL Serer agent to evaluate the service according to certain schedule and log that.
    • On Change Prevent: The policy is enforced. No one will be able to bypass the policy as long as it’s enabled
    • On Change Log: When someone tries to bypass the policy, this is let go, and just logged

    The next feature was Multi Server T-SQL. This is a small SQL Server Management Studio (SSMS) feature that is still great. Simply, this enables you to right click the top of the Servers tree in SSMS, choose new query, and the new query you write gets executed on all the servers you have registered in SSMS. Because this thing is on the client side, the registered servers can be any version (well, I think I mean SQL Server 2000+ still).

    The next demo was on PowerShell Integration. Being able to write something like "CD [ServerName]", "Dir" (gets DB list), "CD [DB Name]", "CD Tables", "Dir" (gets stables list in the DB) is really fun thing to do :D. This is intended to replace SQLCMD old SQL command tool as said by Meshref. I asked him whether I need to do anything on the server to access it via PowerShell on another machine, and he said it’s the same stuff required to use SSMS against it from another machine – interesting!

    Then he demoed SQL Server Intellisense. I don’t need to talk much about this I guess :). Meshref stated that they do caching of the objects you use to enable some sort of "Client Complication" as he called it, which is validating your query (including column and parameter names, etc) when working against a remote Server without having to actually send the query to it.

    The next big thing was "Data Collection Framework". That’s a SQL Agent based feature that is very useful for dataware housing through it’s performance monitoring collection sets and their collection items. He demoed us sample reports of what is collected and it was SQL Objects usage reports, and performance measures (CPU, Memory, etc). The two questions he was about this feature was that whether this requires SQL Reporting Services, whose answer was No, and whether it’s available to consume through SMO APIs, and the answer was yes.

    The last thing he showed before the session ends was a small [x] that appears next to objects in SSMS when they are not compliant with current policies. Good to see. Actually the rest of the session was mainly weird questions from some attendees. Maybe I talk about that in a next post

    Conclusion (You knew there has to be one!)

    OK, it’s morning already, and today is suddenly yesterday. I just wanted to say that I really enjoyed the day and the cool guys. The day was great, and I wanted to tell .NETwork what I believe is missing here.

    Actually the .NETwork guys as I mentioned have made great success in setting up sessions. You made a great frequency. You maintained communication between half or so of the group members, but this leads to ask about the next step. I believe (as I said to Mahmoud) that there should be friendly group gatherings with even higher frequency than the events. Those can always be with little number of guys and with normal talks without sessions or having single session in the meeting. That’s mainly how I hear about usergroup most frequent activities, and I’d love to see it. I believe that this will eventually attract more professional developers, whose presence will help raise the levels of the starting level developers, because with having starters as the majority always, you find yourself sort of stuck in certain level of knowledge exchange instead of increasing that level. I think having regular gatherings in certain times as that "3rd week of a month" intention as well as more smaller gatherings will bring more developers whose presence can take the hands of those starters. It’ll take months to be sensed though. I’m not talking about 3 or 4 months here, but 7 or 10, but that’s affordable I believe as some guys tried for few years.


    To everyone around, I’d like you to check the usergroup and attend the next gathering. I’ll post about it enough time before it happens and will link to the session slides and videos as soon as I know they’re available, but, don’t count on me, and check the usergroup yourselves ;)