Connecting Tech Pros Worldwide Help | Site Map

Web Service (Dynamic URL)

  #1  
Old November 19th, 2005, 02:04 PM
Maziar Aflatoun
Guest
 
Posts: n/a
Hi,

Is there a way to connect to a Web Service dynamically at runtime (Web
Reference URL)? I have always used Visual Studio to create a Web Reference
and then used it in my code. However, that always requires the URL to the
Web Service to be the same on the staging site and the production site. Now
I have two instances of the same application running (Staging site and
Production) and want to store the URL in a file instead. Is there a way to
do this?

ex. Web.Config AppSetting <add key="WebServiceURL"
Value=http://....webserv.asmx>

Thank you
Maz.


  #2  
Old November 19th, 2005, 02:05 PM
Dave Fancher
Guest
 
Posts: n/a

re: Web Service (Dynamic URL)


You can dynamically set the URI of a web service using web.config but you
need to edit the proxy class to do it. You can get to the proxy class
through the object browser (or you can open it directly by navigating through
the web references folder structure). Once in the proxy class, just look for
the URI and replace it with a read from your web.config.

One drawback to this is that if you need to regenerate your proxy class,
you'll need to update the URI again.

HTH
----
http://www.davefancher.com
  #3  
Old November 19th, 2005, 02:12 PM
MattB
Guest
 
Posts: n/a

re: Web Service (Dynamic URL)


Maziar Aflatoun wrote:[color=blue]
> Hi,
>
> Is there a way to connect to a Web Service dynamically at runtime (Web
> Reference URL)? I have always used Visual Studio to create a Web Reference
> and then used it in my code. However, that always requires the URL to the
> Web Service to be the same on the staging site and the production site. Now
> I have two instances of the same application running (Staging site and
> Production) and want to store the URL in a file instead. Is there a way to
> do this?
>
> ex. Web.Config AppSetting <add key="WebServiceURL"
> Value=http://....webserv.asmx>
>
> Thank you
> Maz.
>
>[/color]

I just have a web.config setting (in appSettings) like this:

<add key="MyApp.localhost.MyService"
value="http://10.10.10.1/VirDir/MyService.asmx"/>

I have a Web Reference to my service on localhost that I use for testing
and development. If I want to point to somewhere else this entry
redirects to another location without having to modify anything else.

HTH!

Matt
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bugs in .NET 3.5 Web Service (Dynamic) =?Utf-8?B?Sm9yZGFuIFou?= answers 1 February 22nd, 2008 06:35 PM
Help with my my Hello World web service Chad answers 1 January 28th, 2006 03:05 PM
Dll, windows dorm, configuration file, web service Iwan Petrow answers 2 November 17th, 2005 04:23 AM
Web Service Dynamic URL Problem Wajih-ur-Rehman answers 0 November 15th, 2005 08:26 AM