dynamically connect to webservice

Discussion in 'ASP .Net' started by Ed S, Nov 29, 2003.

  1. Ed S

    Ed S Guest

    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
    Ed S, Nov 29, 2003
    #1
    1. Advertising

  2. 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>
    ----------------------------------------------

    "Ed S" <ed-s.-a-t-.nospam.com> wrote in message
    news:#...
    > 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
    >
    John Timney \(Microsoft MVP\), Nov 29, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Otis Mukinfus
    Replies:
    3
    Views:
    901
    Juan T. Llibre
    Jul 8, 2005
  2. Replies:
    3
    Views:
    40,154
    Roedy Green
    Nov 16, 2005
  3. Replies:
    2
    Views:
    263
  4. Mohsen Pahlevanzadeh

    Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    3
    Views:
    142
    Mohsen Pahlevanzadeh
    Sep 18, 2013
  5. Mohsen Pahlevanzadeh

    Re: Qt connect and first connect or unicode

    Mohsen Pahlevanzadeh, Sep 17, 2013, in forum: Python
    Replies:
    0
    Views:
    109
    Mohsen Pahlevanzadeh
    Sep 17, 2013
Loading...

Share This Page