dynamically connect to webservice

E

Ed S

Hi All,

We're upgrading our web project - currently we have a web app and a web
service - both written in C#. The web app communicates with the web
service for login authentication, the list of who's logged in, messaging
between logged in users, etc. For this first pass, we hardcoded the
location of the web service to localhost/MyWebService. Now, we want to
allow more than one web app, but still have only one web service.
Obviously we can't have the hardcoded localhost/MyWebService anymore. I
was thinking of storing the URL of the webservice in the registry of
each IIS machine that has the web app installed. Now the hard part -
how do I dynamically get the web app to comminicate with a web service
that I don't know its URL at compile time? Any help / nudges in the
right direction are greatly appreciated.

Thanks in advance,

--Ed
 
J

John Timney \(Microsoft MVP\)

You can set the URL to the webservice dynamically at runtime from a setting
held somewhere like web.config

service = new thingService();
service.Timeout = 10000;
service.Url = ConfigurationSettings.AppSettings["WebServiceUrl"];

If your using VS.NET then choose the properties of the web service and
change the "Url Behavior" from "Static" to "Dynamic". This creates an entry
in the <appSettings> section of the Web.Config file that contains the Url
string.
--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top