简体   繁体   English

面向服务的体系结构和不断发展的应用程序之间共享的对象

[英]Service Oriented Architecture and evolving objects shared between applications

I'm about to begin writing a suite of WCF services for a variety of business applications. 我将开始为各种业务应用程序编写一套WCF服务。 This SOA will be very immature to begin with and eventually evolve into a strong middle-ware layer. 这种SOA一开始会非常不成熟,最终会演变为强大的中间件层。

Unfortunately I do not have the luxury of writing a full set of services and then re-factoring applications to use them, it will be a iterative process done over time. 不幸的是,我没有编写完整的服务然后重构应用程序以使用它们的奢侈,这将是一个随着时间推移而进行的迭代过程。 The question I have is around evolving (changing, adding, removing properties) business objects. 我的问题是围绕发展(更改,添加,删除属性)业务对象。

For example: If you have a SOA exposing a service that returns obj1. 例如:如果您有一个SOA公开返回obj1的服务。 That service is being consumed by app1, app2, app3. 该服务正在由app1,app2,app3使用。 Imagine that object is changed for app1, I don't want to have to update app2 and app3 for changes made for app1. 想象一下,对象已更改为app1,我不想为app1所做的更改而必须更新app2和app3。 If the change is an add property it will work fine, it will simply not be mapped but what happens when you remove a property? 如果更改是添加属性,它将正常工作,将不会被映射,但是删除属性会发生什么? Or change a property from a string to an int? 或将属性从字符串更改为int? How do you manage the change? 您如何管理变更?

Thanks in advance for you help? 在此先感谢您的帮助?

PS: I did do a little picture but apparently I need a reputation of 10 so you will have to use your imagination... PS:我确实做了一些描述,但显然我需要10点的声誉,因此您将不得不发挥自己的想象力...

The goal is to limit the changes you force your clients to have to make immediately. 目的是限制您迫使客户立即进行的更改。 They may eventually have to make some changes, but hopefully it is only under unavoidable circumstances like they are multiple versions behind and you are phasing it out altogether. 他们可能最终必须进行一些更改,但是希望它只能在不可避免的情况下进行,例如它们后面有多个版本,而您将完全淘汰它们。

Non-breaking changes can be: 不变的更改可以是:

  1. Adding optional properties 添加可选属性
  2. Adding new operations 添加新操作

Breaking changes include: 重大更改包括:

  1. Adding required properties 添加所需的属性
  2. Removing properties 删除属性
  3. Changing data types of properties 更改属性的数据类型
  4. Changing name of properties 更改属性名称
  5. Removing operations 删除作业
  6. Renaming operations 重命名操作
  7. Changing the order of the properties if explicitly specified 如果明确指定,则更改属性的顺序
  8. Changing bindings 更改绑定
  9. Changing service namespace 更改服务名称空间
  10. Changing the meaning of the operation. 更改操作的含义。 What I mean by this, for example, is if the operation always returned all records but it was changed to only return certain records. 我的意思是,例如,如果该操作始终返回所有记录,但是将其更改为仅返回某些记录。 This would break the clients expected response. 这将破坏客户的预期响应。

Options: 选项:

  1. Add a new operation to handle the updated properties and logic. 添加一个新操作来处理更新的属性和逻辑。 Modify code behind original operation to set new properties and refactor service logic if you can. 如果可以,请在原始操作后修改代码以设置新属性并重构服务逻辑。 Just remember to not change the meaning of the operation. 只要记住不要更改操作的含义即可
  2. If you are wanting to remove an operation that you no longer want to support. 如果要删除不再需要的操作。 You are forcing the client to have to change at some point. 您正在强迫客户端在某个时候进行更改。 You could add documentation in the wsdl to let client know that it is being deprecated. 您可以在wsdl中添加文档,以使客户端知道它已被弃用。 If you are letting the client use your contract dll you could use the [Obsolete] attribute (it is not generated in final wsdl so that's why you can't just use it for all) 如果让客户使用合同dll,则可以使用[已过时]属性(它不是在最终的wsdl中生成的,因此这就是为什么不能全部使用它的原因)
  3. If it is a big change altogether, a new version of the service and/or interface and endpoint can be created easily. 如果完全是一个很大的更改,则可以轻松创建服务和/或接口和端点的新版本。 Ie v2, v3, etc. Then you can have the clients upgrade to the new version when the time is right 即v2,v3等。然后,您可以在适当的时候让客户端升级到新版本

Here is also a good flowchart from “Apress - Pro WCF4: Practical Microsoft SOA Implementation” that may help. 这也是“ Apress-Pro WCF4:实用的Microsoft SOA实施”中的一个很好的流程图,可能会有所帮助。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM