I have a web service client application that connects to a 3rd party's web service. The 3rd party has updated their web service so now my client app fails with SOAP exceptions. Unfortunately, I can't simply update my app to work with the new web service since some of my users will still be using the old web service. So basically I'd like to be able to work with either version of the web service using a single version of my client app.
Since Visual Studio generates a bunch of code that I compile against when a web reference is added, I now have two files: one generated for each version of the web service. Both of the APIs are actually identical, it is just the underlying SOAP messages that seem to have changed. I've put each of these generated files into their own namespace to avoid collisions. So now I'd like to be able to choose which namespace to use at runtime (based on a config parameter).
For example:
if (useOldVersion)
using OldVersionNamespace;
else
using NewVersionNamespace;
Obviously, this would never work since there would be no way to compile the code that references elements in this namespace. Is there an easy way to deal with this issue? Maybe I could use reflection to do what I need at runtime?
The only thing I can really think of would be to literally copy/paste my current code into two different files, the only difference being which namespace is used at the top. This seems like a really bad idea though.