标签:
WCF contracts are version tolerant by default. Figure 1 and Figure 2 summarize typical changes to service contracts and data contracts and describe the impact to existing clients. In short, the DataContractSerializer allows missing, non-required data and ignores superfluous data for service contracts, data contracts and similarly, message contracts. Only the removal of operations or the addition or removal of required data causes problems with existing clients.
Figure 1: Service contracts and backward compatibility
Service Contract Changes | Impact to Existing Clients |
---|---|
Adding new parameters to an operation signature |
Client unaffected. New parameters initialized to default values at the service. |
Removing parameters from an operation signature |
Client unaffected. Superfluous parameters pass by clients are ignored, data lost at the service. |
Modifying parameter types |
An exception will occur if the incoming type from the client cannot be converted to the parameter data type. |
Modifying return value types |
An exception will occur if the return value from the service cannot be converted to the expected data type in the client version of the operation signature. |
Adding new operations |
Client unaffected. Will not invoke operations it knows nothing about. |
Removing operations |
An exception will occur. Messages sent by the client to the service are considered to be using an unknown action header. |
Figure 2: Data contracts and backward compatibility
Data Contract Changes | Impact to Existing Clients |
---|---|
Add new non-required members |
Client unaffected. Missing values are initialized to defaults. |
Add new required members |
An exception is thrown for missing values. |
Remove non-required members |
Data lost at the service. Unable to return the full data set back to the client, for example. No exceptions. |
Remove required members |
An exception is thrown when client receives responses from the service with missing values. |
Modify existing member data types |
If types are compatible no exception but may receive unexpected results. |
WCF Contracts and Backward Compatibility
标签:
原文地址:http://blog.csdn.net/luckyzhoustar/article/details/46340389