Search code examples
c#web-servicesdatacontract

Impacts of updating a WebService entity definition


I've got a WebService that is used by another application to retrieve data. We need to add a new information on the retrieved entity. For example, let's say you have an entity Product that exposes Name, Price, and you want to add a Provider property.

With the tests I've done, everything seems to work fine if I just update the WebService on the server side, but not the client side : The client side still works, but doesn't have access to the new property, which is what I expected.

My question is the following : Aside from not being able to get the new properties, is there any hidden impact of updating the server-side definition of an entity without updating the client-side definition?

The reason for not updating the client side is for synchronization issues between the deployment of the different tiers / parts of the application. For the purpose of this question, consider that we don't want to create a new entity with new methods to be called for the "enriched entity".


Solution

  • Depending on the client it can cause different issues. Some clients will explode if you send extra data back. In those cases you would want to do one of three things:

    1 - add optional parameters

    If you had getProduct(int id) before you would change it to getProduct(int id, bool includeProvider = false) This would allow you to only return what they expect, since an older client wouldn't send the includeprovider in the request.

    2- Depricate the old call and add a new

    Add a new method and depricate the old.

    3- Version your webservice

    Keep supporting your webservice but create a new one at /v2/<webservice> so that you can easily track clients on different versions through logging.

    My preference is 1 & 3

    Anytime I want to add additional information to a call I just add a new optional include which then includes the new element in the response xml. Anytime I make a functionality change or a change that would break contract I create a new version.

    NOTE: If you supply your client we could better know how it handles additional elements in a response.