Menu

Rest api versioning strategy

3 Comments

rest api versioning strategy

Once services are pushed to production their associated WSDL documents — which represent service endpoints, protocols and related contracts describing operations and messaging — must not be changed. Or, at a minimum, any changes should be backward compatible so that rest clients are not affected when changes are published. In this section I will discuss how WCF contracts support backward compatibility, and explain a few versioning strategies that you might consider for your WCF applications. WCF contracts are version rest 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 api 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. Service contracts api backward compatibility. New parameters initialized to default values at the service. Superfluous parameters pass by clients are ignored, data lost at the service. An exception will occur rest the incoming type from the client cannot be converted to the parameter data type. 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. An exception will occur. Rest sent by the client to the service are considered to be using an unknown action header. Data contracts and backward compatibility. Data lost at the service. Unable to return the full data set back to the client, for example. An exception is thrown when client receives responses from the service with missing values. Version tolerance is a good thing since it gives developers a flexible way to handle change. Since the DataContractSerializer is version tolerant, in theory you can refrain from officially versioning contracts and endpoints that expose those contracts until a breaking change is introduced such as removing operations from a service contract, or adding or removing required members from a data contract. There are also potential side-effects of version tolerance:. If you add new operations to a service contract only clients that reference the latest WSDL will know about those operations and you will not be able to track which of your existing clients have updated their WSDL unless you expose a new endpoint when changes are made. If you add non-required data members to a data contract you may have to write extra code to initialize missing values to something meaningful — as api to using the default value. If you remove non-required data members from a data contract you may have round-trip issues where data passed to services or returned to clients is lost. It may be difficult to track problems if you do not keep track of different versions of contracts, as changes are made to production. It is important to choose an appropriate versioning strategy that satisfies the sometimes conflicting need for agility and productivity vs. Here are a few versioning strategies strategy consider:. Rely on backward compatibility for as long as possible and avoid formal contract and endpoint versioning until compatibility is broken. This approach is useful in agile environments that require frequent updates to production code. Perform formal contract and endpoint versioning for any strategy to a service strategy, data contract, message contract or other contract-related or endpoint-related changes. This approach is best in environments what have less frequent production updates or that require detailed tracking of any and all changes. Perform formal contract and endpoint versioning when contracts or endpoints are modified in a way that your policy requires tracking the change. For example, your policy might be to allow new operations to be added to a service contract, but if any changes are made to existing operations, or if any data contracts change such that they are semantically different, it requires versioning. This approach lies strategy between agile and strict versioning. The agile approach to versioning — shown in Figure 3 — means making changes to existing data contracts and service contracts without versioning them, or supplying new endpoints. Strict api means providing new data contracts, service contracts and endpoints as shown in Figure 4. Agile versioning through the same service contract and endpoint. Strict versioning through a new service contract and unique endpoint. It is best to decide on a versioning policy before you release versioning first version to production. Make a copy of the original contract with a new interface type name, the same rest name and a new namespace. Make any required modifications to the contract definition. Implement the new service contract on the same service type if possible. You can use explicit contract implementation to funnel requests to the different method implementations if necessary. This can be a better approach if there are significant changes to the service implementation, or if api service security behaviors will be different from the original service. Figure 5 shows an example of strict service contract versioning with a shared service implementation. Note that the Name property of the ServiceContractAttribute is the same for both versions of the contract, while the interface type name changes from IServiceA to IServiceA2. Also notice that two service endpoints are configured — one for each contract. Version 1 and api of ServiceAContract with related endpoint configuration. In the accompanying code download for this paper, the following directories contain samples that illustrate service contract versioning: To formally version data contracts is a little more complicated since each data contract is likely tied to business entities that are used by the service tier, the business tier rest the data access tier in the application. I recommend the following approach:. Make a copy of the original data contract and type, but rename the versioning to V1 since this will no longer be actively used each application tier. Modify the business entity implementation as needed to work with the application, and update its data contract providing strategy new namespace. Make a copy of the original service contract and implementation and update it to use the V1 type name. Note that this will not alter the service implementation since the V1 type name should have the original data contract with an versioning name and namespace. Version any service contracts that rely on this new data contract following instructions in the previous section. That includes exposing new endpoints. Modify the original service implementation to forward calls to a V2 service instance after mapping the V1 business entity to the V2 business entity. Figure 6 illustrates this approach. Client-side data contracts should also implement IExtensibleDataObject so that V1 clients will preserve unknown data from a V2 service — assuming that non-strict versioning is used. Although you can implement IExtensibleDataObject at the service as well, it is less likely that a service needs to preserve unknown data since it is the system of record for the application. Suppressing IExtensibleDataObject behavior can protect the service from potential DoS attacks alongside message size and reader quotas set rest the binding. If you are sharing metadata such as data contract definitions between clients and services — you can implement IExtensibleDataObject on the data contract types and disable support for this extensibility at the service only. In the accompanying code download for this paper, the following directories contain samples that illustrate data contract versioning and IExtensibleDataObject: Downloads Visual Studio SDKs Trial software Free downloads Office resources SharePoint Server resources SQL Server Express resources Windows Server resources Programs Subscriptions Overview Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups Events Community Magazine Forums Blogs Channel 9 Documentation Strategy and reference Dev centers Samples Retired content. The content you requested has been removed. Articles and Overviews Windows Communication Foundation Windows Communication Foundation Essentials. Windows Communication Foundation Essentials Versioning Strategies. Windows Communication Foundation Essentials. WCF Templates and Tools. Collapse the table of content. This documentation is archived and is api being maintained. Versioning Strategies Articles in this series Introduction Getting Started with WCF WCF Templates and Tools Contracts Versioning Strategies Once services are pushed to production their associated WSDL documents — which represent service endpoints, protocols and related contracts describing operations and messaging — must not be changed. WCF Contracts and Backward Compatibility WCF versioning are version tolerant by default. Service contracts and backward compatibility Versioning Contract Changes Impact to Existing Clients Adding new parameters to an operation signature Client unaffected. Removing parameters from an operation signature Client unaffected. 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. 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 versioning. Remove non-required members Data lost at the service. 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. Choosing a Versioning Strategy Version tolerance is a good thing since it gives developers a flexible way to handle change. There are also potential side-effects of version tolerance: Here are a few versioning strategies to consider: Agile versioning through the same service contract and endpoint Figure 4: Strict versioning through a new service contract and unique endpoint It is best to decide on a versioning policy before you release the first version to production. Versioning Service Contracts To formally version a service contract you should do the following: Versioning Data Contracts To formally version data contracts is a little more complicated since each data contract is likely tied to business entities that are used by the service tier, the business tier and the data access tier in the application. I recommend the following approach: Versioning data contracts Client-side data contracts should also implement IExtensibleDataObject so that V1 clients will preserve unknown data from a V2 service — assuming that non-strict versioning is used. Versioning Strategies Use an agile versioning strategy that relies heavily on backward compatibility for environments that must tolerate frequent change. Use a strict versioning policy for environments that are less frequently updated or require strict change control. Feel free to come up strategy a customized, semi-strict versioning policy that meets your application's needs. Establish a versioning policy ahead of time so that contracts and endpoints can be defined accordingly. Provide explicit name and namespace properties to contracts to support formal versioning. Implement IExtensibleDataObject on data contracts for clients and suppress support for this at the service. Is this page helpful? We appreciate your feedback. Dev centers Windows Office Visual Studio Microsoft Azure More Learning resources Microsoft Virtual Academy Channel 9 MSDN Magazine. Community Forums Blogs Codeplex. Programs BizSpark for startups Microsoft Imagine for students. Adding new parameters to an operation signature. Removing parameters from an operation signature. Modifying return value versioning. Add new non-required members. Add new required members. An exception is thrown for missing values. Modify existing member data types. If types are compatible no exception but may receive unexpected results.

Versioning Strategy

Versioning Strategy

3 thoughts on “Rest api versioning strategy”

  1. AnastasiaK says:

    Washington, DC: Teachers of English to Speakers of Other Languages.

  2. Andrik says:

    This step-by-step includes images showing how to use MS-Word to create the title block, page layout, and works cited list.

  3. andrew_evd says:

    One should regard graduating as proof that you are able to commit yourself to an endeavour, nothing more.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system