策略更新或版本的Web服务? [英] Strategies for updating or versioning web services?

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

问题描述

我很感兴趣地听到不同版本的Web服务是如何被处理的最佳实践。

I'm interested to hear the best practices on how different versions of web services are handled.

要澄清一下,如果你已经有了公开为Web服务的一些网站的方法,那么你想添加一个特性/功能,从而改变这些方法调用的签名,你怎么在没有按的方式处理这牛逼打破所有你的客户是谁目前拨打服务?

To clarify, if you've got some web methods exposed as a web service, then you want to add a feature/functionality and thus change the signature of those method calls, how do you handle this in a manner that doesn't break all of your clients who currently call the service?

你在不同的URL部署该服务?

Do you deploy the service on a different URL?

你把一个版本的方法名称本身(的MyMethod,MyMethodv2等 - 呃..)

Do you put a version in the method name itself (MyMethod, MyMethodv2 etc. - ugh..)

你的版本传递的通话以及一个参数列表方法的一部分?

Do you pass in a version as part of the method call along with a parameter list?

有谁知道谷歌或亚马逊如何处理这种情况与他们丰富的Web服务库?

Does anyone know how Google or Amazon handle this scenario with their extensive Web Service library?

编辑:到目前为止,我发现在这一些好的信息的文章从Oracle 。此外<一href="http://www.gridshore.nl/blog/index.php?/archives/68-Web-service-versioning-in-the-java-world.html"相对=nofollow>一些Java的细节此博客条目​​是有益的。我还是好奇,想看看其他一些方法。

So far I found some good info in this article from Oracle. Also this blog entry on some Java specifics was useful. I'm still curious to see some of the other approaches.

推荐答案

版本的Web服务的典型方法是让客户指定所需的版本。你可以允许进行简单的约束条件,如> 2.0,&所述; 1.5,或= 1.1。当然,你希望尽量减少支持的版本数量为自己的理智。如果客户端不指定版本,你认为最新的。

The typical way of versioning a web service is to have clients specify the version desired. You may allow for for simple constraints, like ">2.0", "<1.5", or "=1.1". Naturally, you want to minimize the number of supported versions for your own sanity. If a client doesn't specify a version, you assume the latest.

有提供该版本的技术而变化。使用,鼓励其他人报头中的URL一些人主张,有些人可能把它作为API调用的参数。几乎没有将改变的方法的名称,虽然。那相当于包或命名空间版本对OSGi的联系洽谈。这会让升级非常困难,而且无法升级更比任何更改实际的服务妨碍的人。

Techniques for providing the version vary. Some advocate using the URL, others encourage headers, some might include it as a parameter of the api call. Almost none would change the name of the method, though. Thats equivalent to the "package" or "namespace" versioning the OSGi link talks about. It'll make upgrading very difficult, and impede people from upgrading more so than any changes to the actual service.

这也取决于你如何访问Web服务。如果你使用REST,那么保持URL的清洁,用头是很有道理的(而且它会是微不足道的本事做查询参数,如果需要的话)。如果你使用SOAP / XMLRPC /不管-RPC,然后把它的URL通常是罚款。

It also depends on how you access your webservices. If you're using REST, then keeping the URL's clean and using headers makes the most sense (and it'd be trivial to hack it in as a query parameter, if need be). If you're using SOAP/XMLRPC/whatever-RPC, then putting it in the URL is usually fine.

修改5/2011 FWIW,虽然我不同意, Apigee的博客建议把该版本中的网址

Edit 5/2011 FWIW, though I disagree, Apigee's blog recommends putting the version in the URL.

如何在客户指定的版本通常是pretty的方便。什么更复杂的是你如何运行所有版本兼任。大多数语言都没有加载多个版本的同一个库/模块/类/函数到同一个运行环境的一种方式(无论是虚拟机,过程或你有什么)。您所提供的OSGi的链接是Java的解决方案,让这一点。

How the client specifies the version is usually pretty easy. Whats more complicated is how you run all the versions concurrently. Most languages don't have a way of loading multiple versions of the same library/module/class/function into the same runtime environment (be it a VM, process, or what have you). The OSGi link you provided is Java's solution to allow this.

在实践中,OSGi的将是矫枉过正的大多数情况。它通常更容易代理去precated请求到另一台服务器或进程。

In practice, OSGi will be overkill for most situations. Its usually easier to proxy deprecated requests to another server or process.

最好的办法版你的服务,但是,是构建可扩展性和灵活性,他们,使他们保持向前和向后兼容。这并不意味着所有版本必须彼此相容,但连续的版本应该与彼此相容。

The best way to "version" your services, though, is to build extensibility and flexibility into them so they remain forwards and backwards compatible. That doesn't mean that all versions must be compatible with each other, but consecutive versions should be compatible with each other.

这篇关于策略更新或版本的Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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