WCF API 部署版本控制 [英] WCF API Deployment Versioning

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

问题描述

我只是想开发 .NET WCF API.我们可能需要经常更新 API.

I was just looking to develop .NET WCF API. We may need to frequently update APIs.

如何管理多个版本的 API 部署?

How to manage multiple versions of API deployment?

推荐答案

对您的服务进行版本控制是一个涉及许多注意事项和指南的巨大主题.

Versioning your services is a huge topic with many considerations and guidelines.

首先,您可以进行不同类别的更改;全断、半断和非断.

For a start, there are different classes of changes you can make; fully-breaking, semi-breaking, and non-breaking.

非破坏性更改(无需对现有客户端进行更改)包括:

Non-breaking changes (no change needed to existing clients) include:

  • 更改服务的内部实现,同时保持公开的合同不变
  • 以不破坏客户端的方式更改合约类型,例如,通过向操作返回类型添加字段(大多数序列化程序在反序列化时遇到意外字段时会引发事件而不是抛出异常)
  • 多态暴露新类型(使用 ServiceKnownType 属性)
  • 更改服务的实例管理设置(每次调用到单例、无会话到会话等,尽管有时这需要配置甚至代码更改)

半破坏性更改(通常可以在客户端进行配置)包括:

Semi-breaking changes (usually can be configured on the client) inlcude:

  • 更改服务的位置
  • 更改服务公开的传输类型(尽管从双向传输更改为单向传输 - 例如 http 到 msmq - 可能是一个完全破坏性的更改)
  • 改变服务的可用性(通过使用服务窗口等)

完全破坏性的更改(需要新版本的客户端)包括:

Fully-breaking changes (need new version of the client) include:

  • 更改服务操作签名
  • 以破坏性的方式更改公开的类型(删除字段等)

当您要进行半破坏性或完全破坏性的更改时,您应该评估执行此操作的最佳方式.您是强制所有客户端升级以使用新版本,还是在不同端点共同托管两个版本的服务?如果您选择后者,那么您将如何控制和管理这可能引入的不同版本控制依赖项的传播?

When you are going to make a semi or fully breaking change, you should evaluate the best way of doing this. Do you force all your clients to upgrade to use the new version, or do you co-host both versions of the service at different endpoints? If you choose the latter then how will you control and manage the propagation of different versionning dependencies which this may introduce?

极端情况下,您可以研究动态端点解析,即客户端使用某种解析器服务解析合适的端点以在运行时调用.

Taken to an extreme, you could look into dynamic endpoint resolution, whereby the client resolves the suitable endpoint to call at runtime using some kind of resolver service.

这里有很好的读物:http://msdn.microsoft.com/en-us/library/ms731060.aspx

这篇关于WCF API 部署版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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