Version compatibility of WCF Development

Source: Internet
Author: User

Because we will always update the WCF Service or extend the new WCF Service, we have to face a problem-the version control problem of WCF.

Once published, the WSDL contract is determined.
-Backward compatibility is required.
Theoretically, the policy can be changed.
-New Security Policy
-Additional reliability features
-Metadata Exchange is used for rule discovery.
If the client can dynamically handle changes, it is safe to only change the policy.

Version compatibility
• By default, the WCF contract provides version compatibility support.
• All service contracts, data contracts, and message contracts:
-Data that is not required (non-required) is allowed to exist.
-Excessive data can be ignored.
• Datacontractserializer provides compatibility support
• Proper changes do not affect existing clients or servers

The following table details the impact on the client after the service contract changes:

Changes in service contracts Impact of service contract changes on existing clients
Add new parameters to the operation Signature
  • The client will not be affected
  • New parameters are initialized to the default value in the service.
Delete parameters from the Operation Signature
  • The client will not be affected
  • Extra parameters passed by the client will be ignored, and the data will be lost on the server.
Modify parameter type
  • If the type entered from the client cannot be converted to the Data Type of the parameter, an exception is thrown.
Modify Return Value Type
  • If the value returned from the server cannot be converted to the expected data type in the client operation signature, an exception is thrown.
Add new operation
  • The client will not be affected
  • Because the client does not know the existence of the new addition operation, it will not be called
Delete operation
  • Throw an exception
  • The message sent by the client to the server is considered to use an unknown action header.
Add a new non-required Member
  • The client will not be affected
  • New parameters are initialized to the default value in the service.
Add a new required Member
  • If the value is missing, an exception is thrown.
Delete A non-required Member
  • Server data loss
  • You cannot return all datasets to the client.
  • No exception thrown
Delete a required Member
  • When the client receives a response with missing data from the server, an exception is thrown.
Modify the Data Type of saved members
  • If the type is compatible, no exception is generated, but unknown results may occur.

To describe a scenario, for example, we add a required datamember member to the server, and then re-release the WCF Service, but the client does not update the service reference of WCF, in this case, when the client calls the WCF Service, the WCF throws an exception that lacks necessary data. If a non-required member is added, no exception is thrown and the client can be used normally. This is the so-called version compatibility. Of course, there are still many situations in actual development. As long as multiple tests are needed, there will be no problem. (End)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.