Monday, May 14, 2007

Hosting WCF Service in IIS with WAS (Windows Activation Service)

WCF allows to host the services in serval ways. Every scenario has it specific advantages and it is important to choose the right way to host your processes. The options for hosting are to host in IIS, an executable or a service.

Before Vista it was possible to host only webservices or remoting via HTTP in IIS because there was the limitation till IIS 6.0 that the communcation protocol had to be HTTP(s). It is mentioned in the MSDN that you can actually use WAS without IIS but till now I could not find any sample where this is explained.

The main complexity of hosting in IIS is to set up your IIS to allow TCP/IP for for the server and for the specific webapplication. The steps to get started are to install the WCF Non-HTTP activation components. To do that, go to the Start menu —> Control Panel —> Programs and Features, and then click "Turn Windows Components On or Off" in the left pane. Expand the Microsoft .NET Framework 3.0 node and ensure that the "Windows Communication Foundation Non-HTTP Activation" feature is checked.

Secondly run the following command as Administrator.
c:\windows\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']

Then a new application needs to be created in IIS. In this case I created the TestApp2 application. After creating it it is important to apply the following statement as Administrator.
C:\Windows\System32\inetsrv\appcmd.exe set app "Default Web Site/TestApp2" /enabled Protocols:http,net.tcp.

This makes sure that the application is also accessable via TCP/IP.

Now IIS has been set up to host components. The next step is to create a new project in Visual Studio 2005 of the type WCF Service Library and then remove all the commented text.

To keep the service as simple as possible I made the following implentation.

public interface IMyService
string SayHello(string value);

public class MyService : IMyService
public string SayHello(string value)
return "Hello " + value;

Then two files need to be added. The first one is the definition of the service. This must exist in a file with the extention svc and will be the entry point for IIS to the service. The file in this example is called Service.svc and the content of the file is
<% @ServiceHost Language=C# Debug="true" Service="MyService" %>
The next file that needs to be added is the Web.Config. One of the main things in the Web.Config file is the declaration of the IMetadataExchange contact. This allows to exchange the meta information over TCP/IP.

<?xml version="1.0"?>
<service behaviorConfiguration="ServiceBehavior" name="MyService">
<endpoint binding="netTcpBinding" bindingConfiguration="PortSharingBinding"
contract="IMyService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None"/>
</bindings> <behaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="False"/>
<compilation debug="true"/>

Compile the service and then copy the files web.config and service.svc over to the folder that corresponds with the application you previosly created. In this example it is c:\inetpub\wwwroot\TestApp2. And create the folder Bin where the dll is copied.
The service is not created and can be accessed over TCP/IP. This means that it can possible to check if the methods exist using the Internet Browser.

The client can be either type of application and the reference needs to be set to
net.tcp://localhost/TestApp2/Service.svc. The service proxy is automatically created and can be accessed equalty to any WCF Service.

Tuesday, May 08, 2007

I got the request to make an entry on what kind of tools I use on a day to day basis while developing ASP.NET 2.0 Applications. The main tool I use is of course VS2005 with Team foundation server as the source control system. I separated the other tools depending on the environment they are used from.

Plug-ins for Visual Studio

Simian - Similarity Analyser This tool makes it possible to detect duplicate code within a file, project or solution.
Team Build SidekickAllows to Check the team build in and out.

Plug ins for Internet Explorer

FiddlerAllows to intercept the HTTP Traffic. Very useful to see the content of the files that are requested.
Developer toolbarAllows to check the properties of the elements that are rendered in the browser.

Tools for the build

Cruise Control.NetAllows the continues integration of .NET applications
TFS CruiseControl.Net pluginThe Plug in to use Team Foundation Server with Cruise Control

Tools for the Team Foundation Server

Web UI for the Team Foundation Server
Custom developed RRSfeed
This tool allows to subscribe to all the work items, your work items, the team builds, the check ins via a news reader tool.

There will be more information on the ASP.NET developer tools later.

Friday, May 04, 2007

TeamPlain Web Access for Team System

Today we have installed TeamPlain on our Team Foundation Server. The version we installed is the 2.0 RC.

The only scary moment when installing it on the Team Foundation Server is when you host it in IIS next to the other Sites (Sharepoint , TFS Server, Default WebSite) and hope that IIS is mapping the port correctly.

The tool works great and it is faster then we expected once the firewall port is opened ;)

The only drawback we found till now is the licensing. Although Microsoft claims it is included with the Team Foundation Server licence you actually should have a TFS CAL to access the site. The main reason why we want to use the TFS Web client is not to buy TFS client access licenses for the not developers. So it is going to be interesting to see if MS creates a new type of licenses for web access?

All information