Wednesday, 3 June 2009

Calling one WCF service from another

Over a year ago I hit this problem, and no amount of work would fix it. A year later, having found myself facing it again, I finally found the solution, thanks to this post.

Whilst the solution was simple, I've written my services so they can be unit-tested. Hence references to instances that require the presence of an HttpRequest are not allowed.

The picture below shows my eventual solution. Whilst it has a large number of classes/interfaces, they are each very small and focussed. They combine together extremely well to allow one service to call another, using Inversion of Control to access the child-service's client.

From Tiny drops of knowledge

Wednesday, 29 April 2009

Hiding the WCF .svc extension on IIS 5 or 6

If you're setting up a WCF web service, its nicer to present a URL that does not have the .svc extension in it, i.e.

Instead of

A simple way of achieving this on IIS versions 5 or 6 is using the free ISAPI Rewrite tool, with the following configuration:

# Don't rewrite url's that already contain .svc.

RewriteRule .*\.svc.* - [L]

# Rewrite requests for host to be

RewriteCond %{HTTP:Host}

RewriteRule ^/(.*)$ /service.svc/$1 [L]

Tuesday, 28 April 2009

Load testing a WCF web-service gives a 403 error on IIS 5.1 (XP Pro)

If you're hosting a WCF web service using XP Pro's IIS and checking its thread-safety by hitting with > 20 threads, then its likely you'll be seeing some 403 errors.

This is unfortunately by design. See Jeff Atwood's article on why and how to get around IIS 5.1's shackles.

Thursday, 23 April 2009

Configuring the Identity of an IIS Application Pool

If a web-site needs to run under a specific identity, IIS application pools provide a convenient means of achieving this. However, a reoccurring problem I come up against in setting these up is forgetting to ensure the identity is also a member of the local IIS_WPG group. TechNet has the full story.

So if you get one of these red icons on your Application Pool, check the IIS_WPG group.

Tuesday, 21 April 2009

NUnit's EqualTo tolerance modifier

Comparing generated DateTime values can always be a bit tricky, but today I discovered NUnit's Within modifier that makes life so much easier:

public void CreatedOnDefaultsToNow()
SomeClass someObject = new SomeClass();
Is.EqualTo(DateTime.Now).Within(new TimeSpan(1000)));