I've searched a lot for this but I always get results for passing parameters to a web service. I want to pass a web service object as a parameter into a method if this is possible. My current code is below.
public static string CheckDaysLeft(string serial) { amazonaws.WebService1 MyService = new amazonaws.WebService1(); return MyService.GetDaysLeft(serial).ToString(); } So I have two web services references in my project, localserver and the above amazonaws. Above I am calling this method which contacts the amazon web service and gets the days left for a particular serial number. This is working fine. I want to be able to pass as a parameter into the CheckDaysLeft method which of the two web services to use (localserver or amazonaws). The reason being that if one web service is down, the program will attempt to communicate with the other. I could create the CheckDaysLeft method twice and use the each web service reference in each method but that is not ideal.
How can I do this?
IMyServiceor a base class likeBaseService? In the worst case, the common class would beobject. You could then use theisoperator to check which one you got and perform a cast. Another possible way would be to wrap the service calls into another "proxy" class that has references to both services and performs the calls on the one or the other, so you only have to pass instances of the "proxy".