影响客户的WCF合同变更 [英] WCF contract changes that affect clients
问题描述
我很好奇,如果有人可以概述服务器端上哪种类型的WCF合同(接口)更改,将会破坏试图发送消息的客户端以及原因.我相信WCF可以处理某些差异,但是我不确定您可以安全更改哪些内容,以及不能更改哪些内容.
I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you can change safely, and what you can't.
- 要从OperationContract添加/删除参数吗?
- 添加/删除/更改DataContract的序列化属性?
- 从ServiceContract添加/删除OperationContract?
一个朋友在这里问了类似的问题:
A friend asked a similar question here:
向WCF添加方法ServiceContract破坏了现有的客户?
正如约翰·桑德斯(John Saunders)所指出的那样,更改合同通常不是一个好主意,但是其中内置的东西允许某些版本公差(ExtensionDataObject等?).我只想知道版本公差的灵活性.
As John Saunders pointed out, changing the contract is not usually a good idea, but there are things built in that allow for some version tolerance (ExtensionDataObject, etc.?). I would just like to know how flexible the version tolerance is.
推荐答案
Check out this article on dasBlonde: Versioning WCF Service Contracts
它列出了哪些更改将破坏现有客户端:
It lists what changes will break existing clients:
- 删除操作
- 更改操作名称
- 删除操作参数
- 添加操作参数
- 更改操作参数名称或数据类型
- 更改操作的返回值类型
- 通过显式使用.NET属性或自定义序列化代码来更改参数类型(数据协定)或操作(消息协定)的序列化XML格式
- 修改服务操作编码格式(RPC编码与文档文字)
米歇尔的这篇文章进行了详细说明如何设计更灵活的合同.
This article by Michele explains in more detail how you can design contracts to be more flexible.
这篇关于影响客户的WCF合同变更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!