|
 Wednesday, August 22, 2007
 |
|
 |
|
|
|
|
|
I have been receiving some questions related to the VS 2008 (Beta 2) projects available, and how they compare to the Orcas plug-in to VS 2005 for building WCF projects. I just made a series of posts on the various project templates and how they compare to VS 2005 with the Orcas extensions for WCF. This should help you with the labs in this book, Learning WCF. Here is a list of posts on the subject: Technorati Tags: WCF, VS 2008
|
|
|
 |
|
 |
 |
|
 |
|
|
|
|
|
Template comparison: - VS 2005 + Orcas extensions: WCF Service (new item)
- VS 2008: WCF Service (new item)
The new template in VS 2008 has not changed much. The main difference is the naming convention of project files generated, the separation of service contract and service type files, and the sample service contract and service type code is slightly different. Impact to Learning WCF labs: Anywhere I ask you to add a new WCF Service to a project you should continue with the same instructions. The difference will be in the files generated. - When I ask you to modify the names of the service file I usually have you use the service name, for example, HelloIndigoService.cs. Now, you will rename the service contract source file to use an "I" prefix (for example, IHelloIndigoService.cs) and rename the service type source file to my original recommendation (for example, HelloIndigoService.cs).
- When I ask you to modify code for the service contract or service type, you can modify them in their respective source files. There is no need to merge the two into one file.
Summary of WCF Service new item template in VS 2008: In any project, you can add a new WCF Service item to the project as shown here: This adds a new service contract and service type to the project, in separate files. Technorati Tags: WCF, VS 2008
|
|
|
 |
|
 |
 |
|
 |
|
|
|
|
|
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: And the generated project files include a samples service contract, service, .svc endpoint and web.config with appropriate <system.serviceModel> settings.  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): 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: WCF, VS 2008
|
|
|
 |
|
 |
 |
|
 |
|
|
|
|
|
Template comparison: - VS 2005 + Orcas extensions: WCF Service (from New Web Site)
- VS 2008: WCF Service (from New Web Site)
The new template for WCF Service when generating a new web site in VS 2008 has not changed much. The main difference is the naming convention of project files generated, the separation of service contract and service type files, and the sample service contract and service type code is slightly different. Impact to Learning WCF labs: Anywhere I ask you to create a new web site using the WCF Service, you should continue to do so. The difference will be in the file location where the service contract and service type is located. - When I ask you to modify the name of the .svc file, or modify the @ServiceHost directive, nothing changes - follow the instructions as written.
- When I ask you to delete the generated service contract and service type, you will now have two files to delete instead of just one, in the App_Code directory.
Summary of WCF Service web sites in VS 2008: When you want to host a WCF service in IIS you will turn to the web site templates for WCF. In VS 2008, the same web site template exists for WCF services - the WCF Service template. The following dialog shows creating a file-based web site using this template: I recommend using this template in the following scenarios: - When you are not able to run IIS on the machine. Some corporate environments have this limitation on developer machines. Personally, I think this is a mistake because it also means developers can't test real security behaviors (as in the identities that must be configured so that services can talk to database, etc.)
- When you are not testing security and just want a simple solution you can distribute. For example, when I build code samples it makes them easier to distribute I usually use file-based web sites. That saves you the trouble of creating a virtual application in IIS to run the sample, and generally makes them easier to distribute to folks if they have IIS or not. I can't do this for samples the work with certain security settings in the bindings, however.
You can also create web sites in IIS selecting this template: The end result is the same as you expect with Orcas extensions in VS 2005. The project includes a .svc endpoint with a sample service contract and service in the App_Code directory. The main difference is that now the contract and service are separated into different files (IService.cs and Service.cs): Technorati Tags: WCF, VS 2008
|
|
|
 |
|
 |
 |
|
 |
|
|
|
|
|
Template comparison: - VS 2005 + Orcas extensions: WCF Service Library
- VS 2008: WCF Service Library
The new template in VS 2008 has not changed much. The main difference is the naming convention of project files generated, the separation of service contract and service type files, and the sample service contract and service type code is slightly different. Impact to Learning WCF labs: Anywhere I ask you to create a WCF Service Library, you should follow the same steps. The difference will be in the file location where the service contract and service type is located. - When I ask you to modify the names of the service file I usually have you use the service name, for example, HelloIndigoService.cs. Now, you will rename the service contract source file to use an "I" prefix (for example, IHelloIndigoService.cs) and rename the service type source file to my original recommendation (for example, HelloIndigoService.cs).
- When I ask you to modify code for the service contract or service type, you can modify them in their respective source files. There is no need to merge the two into one file.
Summary of WCF Service Library in VS 2008: The most likely scenario for creating a new WCF service is to create a new WCF Service Library. That is, a class library assembly with a service contract and service type within. Select the template as shown here: It generates the same result as VS 2005 with Orcas extensions, except that the service contract and service type are in separate files (IService1.cs and Service1.cs): Technorati Tags: WCF, VS 2008
|
|
|
 |
|
 |
 Thursday, August 16, 2007
 Thursday, August 09, 2007
 Saturday, March 03, 2007
 |
|
 |
|
|
|
|
|
I have at long last finished the final edits on my WCF book! Whew! Now, you can get early access to the entire book online at O'Reilly here: http://www.oreilly.com/catalog/9780596101626/ In addition, I have posted the code for the book, with instructions to set up examples, here: http://www.thatindigogirl.com/LearningWCFCode.aspx As for this book blog, I will be using it to post errata, updates and more importantly to provide samples and discussions to further what is covered in the book. I hope you enjoy!
|
|
|
 |
|
 |
 |
|
 |
|
|
|
|
|
Updated: 08/08/2007 - added VB.NET lab code Updated: 11/13/2007 - added C# code converted to VS 2008 compatible solutions) You can get all of the labs and code samples for my book from this blog post. If there are any updates to the zip files, I'll post an entry to let you know. The first two links are for the labs and code in C# and VB.NET. The second link is for media files (very large) to support streaming samples in either language. Learning WCF Code (C#) Learning WCF Code (C# - VS 2008) Learning WCF Code (VB.NET) (currently contains only labs, but I will be updating this link to include all samples) Learning WCF Media Files A very special thanks to Peter Young, one of my most throrough reviewers, who was commissioned to convert all labs and samples to VB.NET as he reviewed the book with great attention to detail. For help setting up you'll need Appendix A of my book, you can get that here: Appendix A - Setup Technorati Tags: Learning WCF, WCF
|
|
|
 |
|
 |
|
|
About the Book
|
|
|
|
ON THIS PAGE
|
|
|
|
CATEGORIES
|
|
|
|
ARCHIVES
|
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 29 | 30 | 31 | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 | 11 | | 12 | 13 | 14 | 15 | 16 | 17 | 18 | | 19 | 20 | 21 | 22 | 23 | 24 | 25 | | 26 | 27 | 28 | 29 | 30 | 31 | 1 | | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
|
DASBLONDE
|
Also, see my main blog, dasBlonde, for more:
|
|
|
|
|