Wednesday, August 22, 2007
« VS 2008 (Beta 2) Projects - WCF Web Site... | Main | VS 2008 (Beta 2) Projects - New WCF Serv... »

Template comparison:

  • VS 2005 + Orcas extensions: WCF Service (from New Web Site, file-based)
  • VS 2008: WCF Service Application

This is a new template in VS 2008, but it compares roughly to the new web site WCF Service template if you use file-based web sites. I describe the details and differences below.

Impact to Learning WCF labs:

I don't recommend you use this template for the labs. I instruct you to use the new web site, file-based, WCF Service template where appropriate. This template will confuse you with the labs, and frankly, I don't think this template is very useful.

Summary of the new WCF Service Application template in VS 2008:

There is a new template for WCF services in VS 2008, the WCF Service Application. This new template produces similar results to the file-based web site using the WCF Service template (see my earlier post). The main difference is in the organization of the project files, whish is less ASP.NET and more assembly style. For this reason, I don't think it is valuable. For one, I never put my service code in the host project so the organization of service files outside of the .svc endpoint becomes irrelevant. Furthermore if I am hosting in a web site, I would rather use the familiar ASP.NET project layout than learn a new structure...I think this will confuse developers. I recommend you don't use this template and if you are hosting in IIS or want to use file-based because IIS is not on the machine...use the web site templates.

Having said that, I will still describe the template here.

You start by creating a project using the WCF Service Application template shown here:

wcfserviceapp

And the generated project files include a samples service contract, service, .svc endpoint and web.config with appropriate <system.serviceModel> settings.

wcfserviceappprojectfiles

A few things to note about this include:

  • Unlike when you explicitly generate a new file-based web site, the code for the service is not placed in the App_Code directory. We don't really care, because you'll end up deleting the service files (IService1.cs and Service1.svc.cs) because your services should not be coupled to the host. You'll instead map the .svc endpoint to another service defined in another assembly.
  • Note the separation of files: IService1.cs contains the service contract, Service1.svc is our traditional service endpoint for web hosting (Cassini, IIS or WAS), and the code associated with the .svc file is Service1.svc.cs - just like the familiar code associated with ASP.NET web pages.

To modify the .svc code you have to view the .svc in markup by right-clicking on the View Markup context menu (yet another strange thing about this template...with web site templates you just double-click the .svc file and it opens):

viewmarkup

Then you can modify the code from this:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFServiceApp.Service1" CodeBehind="Service1.svc.cs" %>

To something like this (assuming you reference the HelloIndigo assembly, which has a HelloIndigoService type in it):

<%@ ServiceHost Service="HelloIndigo.HelloIndigoService"  %>

 

Technorati Tags: ,
8/22/2007 7:43 PM Labs (General)  | Comments [2]  |  View reactions  |  Trackback
    About the Book
    ON THIS PAGE
    CATEGORIES
    ARCHIVES
    DASBLONDE

Designed by NUKEATION STUDIOS