WCF contract changes that affect clients

前端 未结 5 1402
南笙
南笙 2021-02-01 10:31

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 W

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 10:57

    Design recommendations for contracts

    1. First version

      1.1. Carefully choose names for all contracts (interfaces, methods, classes and properties). These will be hard to change in future versions.

      1.2. Remember, that following cannot be changed in future: number of method parameters;type of parameters/return values/properties for types not under your control.

    2. Next version

      2.1. If already exists, do NOT change Namespace or Name parameter on any xxxContractAttribute.

      2.2. If already exists, do NOT change Order property of the DataMemberAttribute.

      2.3. Only following changes are allowed:

      • Add method (OperationContract) to interface (ServiceContract)

      • Rename method on interface

      • Rename class (DataContract)

      • Add property (DataMember) to class (DataContract)

      • Rename property on class

      2.4. Any deletion breaks compatibility.

      2.5. Any other change breaks compatibility.

    Here are few useful links:

    • WCF Versioning Guidelines
    • Service Versioning
    • Best Practices: Data Contract Versioning
    • Collection Types in Data Contracts

提交回复
热议问题