Hello,
I've come here to get some advise from the experts. Currently I am
tasked with modifying a web service that currently supports one
product to support multiple products. It needs to be backwards
compatible so other products still work with the same method calls and
the new products need to have methods with the same names, but
different logic.
Currently we keep some credential information from the client that
consumes the service in a session object that we've created upon them
logging in. I've added the product type to the session object.
I have created new object types for each new product that inherit from
the original object which includes all of the methods and override
methods that require different logic.
I would like to know how I could implement this so that when a
webservice method call comes in with a session variable passed that
contains the product type that the correct object's method is called.
i.e.
[WebMethod]
method1(Session session)
{
if (session.sessionType == product1)
return product1.mehtod1;
}
is there any way I can do this without using if/else or switch logic
in each webservice method? I was thinking of a function that maps the
session and returns a type so I can cast from the base object. But I
do not know how to do this, or if it is even possible. Thanks guys!