Programming the Web using WCF 3.5 – ‘Web HTTP Programming Model’

Publishing RSS and ATOM Feeds using WCF 3.5 Syndication Libraries:

Windows Communication Foundation with its 3.5 release provides several new and useful features including capability to publish and consume syndication feeds in a much easier and uniform way, right out of the box. This article focuses on using the WCF 3.5 libraries namely System.ServiceModel.Syndication namespace to create and publish an RSS and Atom feed from the same code base. System.ServiceModel.Syndication provides a framework to perform the syndication leg-work for us including serialization and deserialization of web feeds.

image

HTTP Programming with WCF and the .NET Framework 3.5:

WCF in the .NET Framework 3.5 includes an easy-to-use HTTP programming model, JavaScript Object Notation (JSON) messaging capabilities, and a new syndication API that makes it easy to create and consume syndicated content. With this feature set, WCF is now the service platform of choice for connecting services to Web clients, whether they are ASP.NET AJAX controls, SilverlightTMclients, or even browsers. These features also work in partial trust scenarios (like ASP.NET medium trust) so you can host WCF services in widely available hosting environments. To round it all out, there’s also new tooling integrated into Visual Studio┬«2008 that dramatically reduces the amount of time it takes to get a service up and running.

This means you can build a service that communicates within or across enterprise boundaries using SOAP and WS-*, and you can configure that same service to communicate externally using the protocols of the Web – JSON, RSS & ATOM. 

It starts with a level-setting discussion about some of the important architectural principles in HTTP and the Web, then moves to the new HTTP programming model in WCF, and, finally, to the new syndication API.

  • HTTP message basics
  • Adding information to URIs
  • WCF and HTTP
  • RSS and ATOM with WCF
  •  image

    image

    Use LINQ and .NET 3.5 to Convert RSS to JSON using DataContractJsonSerializer and HttpHandler

    JavaScriptSerializer is marked as obsolete with a note to use the DataContractJsonSerializer instead.  Here is what a generic HTTP Handler would look like that mashes up these techniques using .NET 3.5.

    image

    Creating a JSON Service with WCF 3.5, DataContractJsonSerializer and WebGetAttribute

    image

    image

    Create RSS and Atom Feeds with LINQ and WCF Syndication in .NET 3.5 within ASPX

    image

    …..

    image

    Also directly from MSDN – WCF 3.5 Feature List

    image

    Web Programming Model
    http://msdn2.microsoft.com/en-us/library/bb412169.aspx

    Web Programming Model Samples
    http://msdn2.microsoft.com/en-us/library/bb472415.aspx

    WCF Syndication
    http://msdn2.microsoft.com/en-us/library/bb412202.aspx

    Syndication Samples
    http://msdn2.microsoft.com/en-us/library/bb943474.aspx

    LINQ to SQL vs LINQ to Entities

     

    When Do I Use LINQ to SQL?

    The primary scenario for using LINQ to SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases. In other words, when building an application whose object model is structured very similarly to the existing database structure, or when a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model; you can use LINQ to SQL to map a subset of tables directly to classes, with the required columns from each table represented as properties on the corresponding class. Usually in these scenarios, the database has not and/or will not be heavily normalized.

    image

    When do I use LINQ to Entities?

    The primary scenario targeted by LINQ to Entities is a flexible and more complex mapping scenario, often seen in the enterprise, where the application is accessing data stored in Microsoft SQL Server or other-third party databases.

    In other words, the database in these scenarios contains a physical data structure that could be significantly different from what you expect your object model to look like. Often in these scenarios, the database is not owned or controlled by the application developer(s), but rather owned by a DBA or other third party, possibly preventing application developers from making any changes to the database and requiring them to adapt quickly to database changes that they may not have been aware of.

    image

    Via Introducing LINQ to Relational Data

    Building a ToJSON() Extension Method using .NET 3.5

    Here…Serialize a List<Person> into a string of JSON format

    image

    Here is the Extension method to provide the JSON serialization on the String Type.

    image

    Note: In addition to the JavaScriptSerializer class, .NET 3.5 also now includes a new System.Runtime.Serialization.DataContractJsonSerializer class that you can use for JSON serialization/deserialization

    Via Tip/Trick: Building a ToJSON() Extension Method using .NET 3.5 – ScottGu’s Blog

    Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion AjaxControlToolkit Control

     

    image

    The left pane contains a 2 level hierarchy of categories and subcategories.  As the user selects different subcategories the designer wants the right pane’s content to be updated with the corresponding information.  Just like Outlook, the designer wants the subcategories to be displayed within expanding and collapsing panels. Accordion AjaxControlToolkit.

    The Accordion is not the only toolkit control that allows you to provide multiple panes of content and display them one at a time, the Tab control does this as well.  The trick is deciding what control better meets your requirements.

    Live Demo (IE6, IE7 and FF) | Download (.Net 3.5 and Toolkit Version 3.5.11119.0)

    Via Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion Controls