更新 WebService 实体定义的影响
我有一个 WebService,另一个应用程序使用它来检索数据。我们需要在检索到的实体上添加新信息。例如,假设您有一个公开 Name
、Price
的实体 Product
,并且您想要添加一个 Provider
> 财产。
根据我所做的测试,如果我只更新服务器端的 WebService,而不是客户端,一切似乎都工作正常:客户端仍然可以工作,但无法访问新属性,这就是我预料到了。
我的问题如下:除了无法获取新属性之外,更新实体的服务器端定义而不更新客户端定义是否有任何隐藏影响?
不更新客户端的原因是应用程序的不同层/部分的部署之间存在同步问题。出于此问题的目的,请考虑我们不想创建一个具有为“丰富实体”调用的新方法的新实体。
I've got a WebService that is used by another application to retrieve data. We need to add a new information on the retrieved entity. For example, let's say you have an entity Product
that exposes Name
, Price
, and you want to add a Provider
property.
With the tests I've done, everything seems to work fine if I just update the WebService on the server side, but not the client side : The client side still works, but doesn't have access to the new property, which is what I expected.
My question is the following : Aside from not being able to get the new properties, is there any hidden impact of updating the server-side definition of an entity without updating the client-side definition?
The reason for not updating the client side is for synchronization issues between the deployment of the different tiers / parts of the application. For the purpose of this question, consider that we don't want to create a new entity with new methods to be called for the "enriched entity".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据客户的不同,它可能会导致不同的问题。如果你发回额外的数据,有些客户端会爆炸。在这些情况下,您需要执行以下三件事之一:
1 - 添加可选参数
如果您之前有
getProduct(int id)
,则将其更改为getProduct(int id, bool includeProvider = false)
这将允许您仅返回他们期望的内容,因为较旧的客户端不会在请求中发送 includeprovider。2- 废弃旧的调用并添加新的
添加新方法并废弃旧的。
3- 版本化您的 Web 服务
继续支持您的 Web 服务,但在
/v2/
创建一个新的 Web 服务,以便您可以通过日志记录轻松跟踪不同版本的客户端。我的偏好是 1 & 3
每当我想向调用添加附加信息时,我只需添加一个新的可选包含,然后将新元素包含在响应 xml 中。每当我进行功能更改或更改会违反合同时,我都会创建一个新版本。
注意:如果您向客户提供信息,我们可以更好地了解它如何处理响应中的其他元素。
Depending on the client it can cause different issues. Some clients will explode if you send extra data back. In those cases you would want to do one of three things:
1 - add optional parameters
If you had
getProduct(int id)
before you would change it togetProduct(int id, bool includeProvider = false)
This would allow you to only return what they expect, since an older client wouldn't send the includeprovider in the request.2- Depricate the old call and add a new
Add a new method and depricate the old.
3- Version your webservice
Keep supporting your webservice but create a new one at
/v2/<webservice>
so that you can easily track clients on different versions through logging.My preference is 1 & 3
Anytime I want to add additional information to a call I just add a new optional include which then includes the new element in the response xml. Anytime I make a functionality change or a change that would break contract I create a new version.
NOTE: If you supply your client we could better know how it handles additional elements in a response.
除非您不删除客户端正在使用的属性(即您只是添加道具),否则它应该可以工作。唯一的缺点是没有遵循持续集成原则,有时候强行去做你会感觉很不舒服:)
Unless you are not removing properties the client is using ( ie you are just adding props ) it should work. The only drawback is not following the continuos integration principle, and you will feel very unconfortble when you will doing it forcibly since some times :)