locked
Versioning Services RRS feed

  • Question

  • User-665281982 posted

    I would like to get an explanation of how this scenario:

    1) For a client, there may be several possible versions of a service, where the same may have happened in datacontract changes in method signatures, or whatever else happens, which is in the business rule after implementation of the interface.

    I know there is DataContracts versioning, but and if there are changes in the rules when implementing the contract?

    Monday, March 25, 2013 3:11 PM

Answers

  • User-1000095884 posted

    Hi,

    You can do version control processing through contract inheritance, which can be used to create a new contract that extends existing contracts.

    To use this feature, define a new service contract interface that inherits from the old service contract interface, then add methods to the new interface. You then change the service that implements the old contract to implement the new contract and change the "versionOld" endpoint definition to use the new contract. To "versionOld" clients, the endpoint will continue to appear as exposing the "versionOld" contract; to "versionNew" clients, the endpoint will appear to expose the "versionNew" contract.

    For more information about service versioning, check Service Versioning.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 26, 2013 10:32 PM
  • User-1000095884 posted

    Hi,

    Assume there is a service interface IMyServiceA, like :

    [ServiceContract]
        public interface IMyServiceA
        {
            [OperationContract]
            string Operation1();
            [OperationContract]
            string Operation2();
        }
    

    Now, we need add a new opration, Operation3, we can do it with inheritance, create a new interface IMyServiceA2, make it inherit from IMyService2, and implement the new interface.

    [ServiceContract]
        public interface IMyServiceA2 : IMyServiceA
        {
            [OperationContract]
            string Operation3();
        }
    

    Then, modify your app.config to use IMyServiceA2.

     <endpoint address="" binding="wsHttpBinding" contract="TestServices.IMyServiceA2">
    </endpoint>
    

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 27, 2013 10:45 PM
  • User-1000095884 posted

    Hi,

    I am not sure what do you mean with business logic here, what is the replationship with the service?

    The changes to services that may be required can be classified into four categories:

    • Contract changes: For example, an operation might be added, or a data element in a message might be added or changed.
    • Address changes: For example, a service moves to a different location where endpoints have new addresses.
    • Binding changes: For example, a security mechanism changes or its settings change.
    • Implementation changes: For example, when an internal method implementation changes.

    When I change the code at the interface implementation ? (only the operation contract implementation, not the parameters.. ) This versioning works ?

    If you mean the operations in the interface, yes, it would work; if you mean the service class( which implement the interface) changes but the interface is not been changed, you just need to create a new class that implement the interface, and update the reference to the new class for a new client.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 1, 2013 2:43 AM

All replies

  • User-1000095884 posted

    Hi,

    You can do version control processing through contract inheritance, which can be used to create a new contract that extends existing contracts.

    To use this feature, define a new service contract interface that inherits from the old service contract interface, then add methods to the new interface. You then change the service that implements the old contract to implement the new contract and change the "versionOld" endpoint definition to use the new contract. To "versionOld" clients, the endpoint will continue to appear as exposing the "versionOld" contract; to "versionNew" clients, the endpoint will appear to expose the "versionNew" contract.

    For more information about service versioning, check Service Versioning.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 26, 2013 10:32 PM
  • User-665281982 posted

    Please, can you give me more examples? 

    thanks

    Wednesday, March 27, 2013 8:11 AM
  • User-1000095884 posted

    Hi,

    Assume there is a service interface IMyServiceA, like :

    [ServiceContract]
        public interface IMyServiceA
        {
            [OperationContract]
            string Operation1();
            [OperationContract]
            string Operation2();
        }
    

    Now, we need add a new opration, Operation3, we can do it with inheritance, create a new interface IMyServiceA2, make it inherit from IMyService2, and implement the new interface.

    [ServiceContract]
        public interface IMyServiceA2 : IMyServiceA
        {
            [OperationContract]
            string Operation3();
        }
    

    Then, modify your app.config to use IMyServiceA2.

     <endpoint address="" binding="wsHttpBinding" contract="TestServices.IMyServiceA2">
    </endpoint>
    

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 27, 2013 10:45 PM
  • User-665281982 posted

    Thanks for the answer and examples. Only one more question. When I change only the business logic (BLL) that the service calls ? This versioning works?

    When I change the code at the interface implementation ? (only the operation contract implementation, not the parameters.. ) This versioning works ?

    thanks

    Thursday, March 28, 2013 6:40 AM
  • User-1000095884 posted

    Hi,

    I am not sure what do you mean with business logic here, what is the replationship with the service?

    The changes to services that may be required can be classified into four categories:

    • Contract changes: For example, an operation might be added, or a data element in a message might be added or changed.
    • Address changes: For example, a service moves to a different location where endpoints have new addresses.
    • Binding changes: For example, a security mechanism changes or its settings change.
    • Implementation changes: For example, when an internal method implementation changes.

    When I change the code at the interface implementation ? (only the operation contract implementation, not the parameters.. ) This versioning works ?

    If you mean the operations in the interface, yes, it would work; if you mean the service class( which implement the interface) changes but the interface is not been changed, you just need to create a new class that implement the interface, and update the reference to the new class for a new client.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 1, 2013 2:43 AM