Ways to version WCF services

…衆ロ難τιáo~ 提交于 2019-12-06 09:56:51

问题


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?


回答1:


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).




回答2:


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.

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.

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.



来源:https://stackoverflow.com/questions/10294524/ways-to-version-wcf-services

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!