Dear SOA Coders
- March 10th, 2010
- Posted in Uncategorized
- By AMB
- Write comment
Please version your services. Seriously, I cannot express the irrational irritation I feel whenever I encounter an unversioned web service. And while I would like say that it makes me go all Bruce Banner and go on campaigns of violence against service authors, really I just say mean things about them and question their intelligence, heritage, grooming habits. Truly, you wouldn’t like me when I’m angry; I can be pretty damned annoying.
Where was I? Right, web service versioning. Probably the best way to handle it is to add another web method to all your services that returns version of the executing assembly. In C# and other .NET languages, this is pretty simple:
1 2 3 4 5 6 7 8 9 10 11 12 | [WebMethod] public string GetVersion() { Version versionObj = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string versionString = versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build + "." + versionObj.Revision; return versionString; } |
Another option for web service versioning is simply to include the version as an output parameter on every method. In most cases this is overkill, but in instances where the web service changes often and/or without notice, it might not be such a bad idea.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public static string Message { get; set; } [WebMethod] public string GetMessage(out string currentServiceVersion) { currentServiceVersion = GetVersion(); return Message; } [WebMethod] public void SetMessage(string newMessage, out string currentServiceVersion) { currentServiceVersion = GetVersion(); Message = newMessage; return; } |
Of course this method has the disadvantage that, even though you probably only need to check the version rarely (e.g. when issues arise or when deploying new versions of consumer apps), the web service does the work of retrieving the version every time. It also incurs a slight network traffic cost, since you’re passing the version back with every response message.
I would have thought that attaching some kind of client-accessible version to your web services would be common sense or, at the very least, common best practice. But we’ve been fighting this battle in the context of my day job, trying to get a client to version the services we rely on for integration. This after several cases in which QA saw issues in testing which, after investigation, turned out to be due to web services that hadn’t been updated as promised or, worse yet, had been “updated” without our knowledge.
So yes: version your services. It’s not that hard, and can save everyone a lot of angst. Especially those who would otherwise have to listen to me bitch.

No comments yet.