This is a little complicated to explain but I have some web services on a
machine that work great.
The problem is that I have run into a situation where I need to set up my
program to access one or another (could also be 3) different web servers to
use these Web Services. The Web Services are identical on all the machines.
I tried just changing the URL of the Web Services and cannot make it work.
I then decided to create 2 identical web services (one for each machine) and
then use a generic type to use in my code.
The 2 web Servers are Earth and Saturn.
I originally had a Web Service called RemoteUserService, which has a method
fetchRemoteUserInfo.
To make this work I created 2 web services and called them RemoteUserEarth
and RemoteUserSaturn. Both Services are identical except for the URL they
point to and their Namespaces (ClassLibrary4.RemoteUserEarth and
ClassLibrary4.RemoteUserEarth).
I then tried all combinations of defines to make this work and kept coming
up with compiler errors - mainly "Cannot Implicitly assign" errors.
I came closest with:
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();
object remoteUserService;
remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;
This compiles fine, but I can't use the remoteUserService in my code as it
is an object.
ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);
This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".
What I am trying to do is get remoteUserService be the generic class that I
can using throughout my code. I don't want to create multiple instances of
the same code when the only difference is the machine I point to. If I then
have to set up a 3rd machine, I would have recreate all my code again for
the 3rd machine. I would much rather just set up another variable, such as
remoteUserServiceMars which I just assign to remoteUserService when I point
to that machine.
Can this be done?
Thanks,
Tom