2

Is there a nice way to version the data types and methods in WCF services?

Something like this would be nice to include a method in version 1.0 to version 4.5.

[ServiceContract()]
interface ITradeTrackingService
{
    [OperationContract()]
    [Version(1.0, 4.5)]
    void PublishQuote(Quote quote);
}

And something simular on datatypes.

Then i would like to in my url do like this:

server.com/ws/2.3/

And then in my Global.asax BeginRequest do something like this:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    Service.Version = someParsingOfUrl(); // return 2.3;
}

And then the correct methods were exposed and the correct values in the datatypes were exposed.

Is this just me dreaming or can this be done in some way?

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
Andreas
  • 6,958
  • 10
  • 38
  • 52
  • 1
    possible duplicate of [Best practices for versioning your services with WCF?](http://stackoverflow.com/questions/36999/best-practices-for-versioning-your-services-with-wcf) – Cheeso Apr 26 '12 at 01:57

2 Answers2

7

There's a bunch of stuff about service versioning out there - there are many things you need to consider.

The lowest friction article I have read about versioning is outlined here, however, it seems a little "hacky" in places, specifically where you use interface inheritance to version your endpoint contract (see an example here).

Microsoft themselves have rather alot to say about it (here).

Community
  • 1
  • 1
tom redfern
  • 30,562
  • 14
  • 91
  • 126
1

Microsoft has published an excellent article on Versioning Strategies in WCF.

In the article, the author discusses the two main methods of Versioning Service Contracts:

Agile Versioning: Rely on backward compatibility for as long as possible and avoid formal contract and endpoint versioning until compatibility is broken. This approach is useful in agile environments that require frequent updates to production code.

enter image description here

Strict Versioning: Perform formal contract and endpoint versioning for any change to a service contract, data contract, message contract or other contract-related or endpoint-related changes. This approach is best in environments what have less frequent production updates or that require detailed tracking of any and all changes.

enter image description here

There is also an approach described called Semi-Strict Versioning which lies between Agile and Strict Versioning.

The linked article discusses versioning of Data Contracts as well.

Derek W
  • 9,708
  • 5
  • 58
  • 67