开发者

WCF Message contract versioning

I would like add a new MessageBodyMember to my MessageContract which refers to a new Datacontract.

Will there be an issue?.

What is the best way to handle message contract 开发者_如何学编程changes?.

How to know whether the addition of a new MessageBodyMember would be a breaking or non-breaking change?.


Message contract versioning is handled in http://msdn.microsoft.com/en-us/library/ms730255.aspx:

Occasionally, you may need to change message contracts. For example, a new version of your application may add an extra header to a message. Then, when sending from the new version to the old, the system must deal with an extra header, as well as a missing header when going in the other direction.

The following rules apply for versioning headers:

  • WCF does not object to the missing headers—the corresponding members are left at their default values.

  • WCF also ignores unexpected extra headers. The one exception to this rule is if the extra header has a MustUnderstand attribute set to true in the incoming SOAP message—in this case, an exception is thrown because a header that must be understood cannot be processed.

Message bodies have similar versioning rules—both missing and additional message body parts are ignored.

So that means that you can add and remove MessageBodyMembers, without breaking compatibility. Be careful with changing member types. Make sure they are serialized equally to remain compatible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜