Dynamic web reference in a DLL

G

Greg

Hi,

I have a class library (DLL) that references a web service. This DLL is
referenced by web applications. The problem is, I need to reference a
development, test, or production version of the web service depending on
whether I'm in the development, test, or production environment. Is there a
way to dynamically change which version is referenced?

I found an article at Microsoft
(http://msdn2.microsoft.com/en-us/library/5k10s063(VS.80).aspx) that
describes how to do this if the web app references the web service directly,
but I can't figure out how to make it work when it's the DLL that references
the web service.

So is this even possible? Am I missing something obvious? I'm kind of a
web service novice.

Thanks!
Greg

ps. This is VS 2005, if that's important.
 
J

John Saunders [MVP]

Greg said:
Hi,

I have a class library (DLL) that references a web service. This DLL is
referenced by web applications. The problem is, I need to reference a
development, test, or production version of the web service depending on
whether I'm in the development, test, or production environment. Is there
a
way to dynamically change which version is referenced?

I found an article at Microsoft
(http://msdn2.microsoft.com/en-us/library/5k10s063(VS.80).aspx) that
describes how to do this if the web app references the web service
directly,
but I can't figure out how to make it work when it's the DLL that
references
the web service.

So is this even possible? Am I missing something obvious? I'm kind of a
web service novice.

If you have a class library, then you probably have a class that references
the web service. Let the class expose a property which is the URL of the
service to reference. The consumers of the class library can set this
property before calling on methods that require the web service. The callers
should probably get the URL to use from a settings file.
 
G

Greg

Thanks! After I discovered how to generate a proxy class with wsdl.exe, this
solution worked perfectly.

Thank you!
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top