Monthly Archives: August 2008

WCF Services – a compatibility hack

I’ve recently had to start developing a set of WCF services for my company to use.  All good stuff, you might say – and tyou’d be right.  For the most part.

The area in which things get “interesting” is around the requirement for backwards-compatibility with some existing .Net 1.1 applications that consume traditional web services.  These applications are horrendously complex, and the fewer changes to the code base we have to make, the better.  With this in mind, we created the WCF services to mirror the old web services as closely as possible and that’s where the fun began.

The issue that set me on a journey of discovery and hackery was around a method that returned a simple boolean type.

public bool NameIsInList(string name)

{

// implementation

return true;

}

Nothing fancy there.  However, exposing the service using basicHttpBinding had an unfortunate side effect.  The method signature was refactored to :

public void NameIsInList(string name, out bool NameIsInListResult, out bool NameIsInListResultSpecified);

Less than ideal.

No matter what I tried (including contacting Amit) I couldn’t make the down-level compatible web service return a simple boolean result.  Given how much effort we would have to go to to update the calling methods in the legacy systems, I had to find another way forward.

In the end, the solution was extremely simple, if a little hacky.  Create an ASMX web service that handled the calls to the WCF service, and presents the legacy apps with the data they expect.

[WebMethod]
public bool NameIsInList(string name)
{
using (MyWcfService.ServiceClient WcfClient = new MyWcfService.ServiceClient(“WSHttpBinding_MyService”))
{
return WcfClient.NameIsInList(name);
}
}

Not the prettiest solution, but it works.

There are a few extra benefits that I wasn’t expecting from this approach, too.  I’ll post about those tomorrow.

Stack Overflow – pretty darned cool

Over the course of the last week, I have been participating in the private beta of a new website, Stack Overflow.

The site is for programmers, by programmers and focussed on – you guessed it – programming.  So far it all looks pretty sweet.  Users aren’t required to register, and more importantly they aren’t required to pay to use the service (I’m looking at you, Experts Exchange!).  The overall quality of questions and answers seems pretty high, although I understand that the site is still in beta.  The quality may change once the site goes live, but the system of self management by the community should keep standard fairly high overall.

If you want to keep up to date with the project, and hopefully learn when the public launch is going to happen check out the blog.