Call a webservice via URL dynamically

N

Norbert Pürringer

Hello there,

is it possible in .NET to call a webservice passing the webservice URL
at runtime instead of creating a web reference with a static URL. I
know that the URL is saved in the reference.cs, but it appears several
times in an attribute, which cannot be easily changed.

Regards,
Norbert
 
C

Cowboy \(Gregory A. Beamer\)

I am sure you can fashion a fully dynamic system, but I am not sure it is
worth it.

In web services, you are coupled to contract. It is "loosely coupled" as you
are coupling to definition of data and not a particular provider.

If you set up one static web reference for development, you can alter it for
production in config. If you want it to be more flexible than this, you can
set up the proxy instantiation to point to a different URL at runtime. In
fact, you can even make a "self-healing" service call by making a call to
UDDI when the initial call fails. You can also save this information to a
file that is checked at start up of your application.

While the method above is not completely dynamic at the programming level,
it works fine and is just about as flexible as a completely custom web
service invocation engine.
 
J

John Saunders [MVP]

Norbert Pürringer said:
Hello there,

is it possible in .NET to call a webservice passing the webservice URL
at runtime instead of creating a web reference with a static URL. I
know that the URL is saved in the reference.cs, but it appears several
times in an attribute, which cannot be easily changed.

You only need to change the Url property of your proxy class. See
http://msdn2.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.url.aspx.

The "Url" values that you are seeing in "attributes" are not actual urls.
They are probably XML Namespaces, and have no direct relationship to the
location of your server.
 
D

Don

Hi,

I'm using .NET 3.5.
There's no Url property for the generated proxy class.

How can I set the Url correctly?

Thanx
Don
 
J

John Saunders [MVP]

Don said:
Hi,

I'm using .NET 3.5.
There's no Url property for the generated proxy class.

How can I set the Url correctly?

There is a Url property if you're using a Web Reference, and not a Service
Reference...
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top