WCF service contract design article

I had a conversation yesterday regarding WCF service contract design with my tech lead at work. Funnily enough, I then got a comment on an old post that afternoon from Ciaran O'Neill which is really about the same topic. I thought that I should write up my thoughts on the subject. See here for the article.

Lying to WCF

There are cases when you need to transmit username/password credentials to WCF without transport security. The times that you should do this are rare because of the obvious security implications of sending credentials over the wire without encryption. One case where this is required is where hardware acceleration is used in a load balancer. The traffic between the load balancer and the client is encrypted, but the traffic between the load balancer and the service host is not. The issue here is t... [More]

WCF Security: Getting the password of the user

A common problem with service security is that username/password security is needed for authentication and authorization at the service boundary, but those same credentials are also required to consume other resources such as a database or underlying service. By default, username/password security will run the authentication and authorization of the credentials but only the username is available to the executing service code. This is typically made available through Thread.CurrentPrincipal.Ident... [More]

Implementing IErrorHandler

As soon as I read about IErrorHandler in Juval Lowy's book, I was sold. This interface in WCF is excellent to use for error handling and shielding at service boundaries. The interface comes with two methods. ProvideFault allows you to handle the error and determine what is returned to the client. This is where exception shielding comes in. The service implementation or any of the layers in the service can throw an exception. The error handler is the opportunity to determine whether the exce... [More]

Xml comments and the include element

I have been doing a lot of work over the last week writing xml comment documentation. I have been compiling the xml output into chm files using SandCastle, [SHFB] and my own [SHFB] wrapper application. I have been increasingly been finding that I am writing remarks that I want to reuse across different methods and properties of several classes in an assembly. Today, I had a particular property scattered among several data contracts for a WCF service that are used for the same purpose and have th... [More]

Static Analysis Rules - Sooner rather than later

I posted the other day that I wanted to create some static analysis rules for [VS]. I have some great ideas for several rules that I want to write in order to do two things. Firstly, I want rules to pick up common mistakes made in coding. Secondly, the rules can be used to enforce coding standards via the Code Analysis TFS checkin policy. To enforce coding standards, I have previously written xpath and regex TFS checkin policy implementations that work off a set of defined rules. I found t... [More]

WCF, SSL and localhost

We encountered an interesting issue at work over the last week. We are writing WCF services and implementing transport security to communicate with IIS. For local development, we had certificates created by a certificate server and configured onto the local IIS. As you would expect, the certificates used the machine name for the common name of the certificate. This is after all the standard procedure. The problem encountered is that the web application project in [VS] stores the url of the proj... [More]

WCF netTcpBinding service in WS2008 Beta 2

Yesterday I got the opportunity to start playing with [WCF] net.tcp services hosted in WAS on Windows Server 2008 (Beta 2). There were a couple of hiccups, but it was surprisingly painless. Firstly, I got the service up and running over wsHttpBinding. One thing I noticed about this is that, unlike XP Pro (and I think Vista), IIS7 on WS2008 doesn't need anonymous set against the svc file for the service endpoint when the rest of the site was running under Windows Authentication. S... [More]

Vista VS2005 installation order

I'm just about to get a new laptop which will be running Vista. This got me thinking about the installation order for VS2005. There are so many bits and pieces to install, but what is the correct order. This is what I'm thinking. Vista IIS Sql Server 2005 Visual Studio 2005 Team System Visual Studio 2005 MSDN documentation Visual Studio for Database Professionals Microsoft Visual Studio 2005 - Update to Support Web Application Projects (this is included in VS SP1) Sql Server 2005 SP2... [More]

ASMX interoperability with WCF

If you have an ASMX client, you can get it to call a WCF endpoint with some restrictions. You have to use the basicHttpBinding on the WCF service and the service implementation (or contract) needs to be decorated with the XmlSerializerFormat attribute. I have encountered a problem under SSL though. I am wanting to use username/basic authentication with the service over SSL. This article makes the following reference: The easiest straightforward way for a successful interoperability scenari... [More]