Groups | Blog | Home
all groups > asp.net webservices > october 2007 >

asp.net webservices : Call a webservice via URL dynamically


Norbert_P=FCrringer
10/29/2007 5:39:21 AM
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
Cowboy (Gregory A. Beamer)
10/29/2007 10:31:54 AM
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.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
[quoted text, click to view]

John Saunders [MVP]
10/29/2007 1:49:23 PM
[quoted text, click to view]

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.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Don
2/27/2008 9:48:55 AM
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


"John Saunders [MVP]" <john.saunders at trizetto.com> a écrit dans le
message de news: OW8tLQlGIHA.5160@TK2MSFTNGP05.phx.gbl...
[quoted text, click to view]

John Saunders [MVP]
2/27/2008 7:12:49 PM
[quoted text, click to view]

There is a Url property if you're using a Web Reference, and not a Service
Reference...
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

AddThis Social Bookmark Button