版本化 WCF 服务的方法 [英] Ways to version WCF services

查看:26
本文介绍了版本化 WCF 服务的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种很好的方法来对 WCF 服务中的数据类型和方法进行版本控制?

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

在 1.0 到 4.5 版本中包含一个方法会很好.

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/

然后在我的 Global.asax BeginRequest 中做这样的事情:

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?

推荐答案

一堆关于服务版本控制的内容那里 - 您需要考虑很多事情.

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

我读过的关于版本控制的最低摩擦文章概述了here 但是,在某些地方似乎有点hacky",特别是在您使用接口继承来对端点合同进行版本控制的地方(参见示例 此处).

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

这篇关于版本化 WCF 服务的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆