Setting web service location dynamically

Discussion in 'ASP .Net' started by Nils Magnus Englund, Feb 21, 2005.

  1. Hi,

    I have a production, test and development environment for my web application
    and a web service (The test web application connects to the test web
    service, and so on).

    Is it possible to let the web services location be set in e.g. Web.config? I
    don't want to recompile the web application every time I move it to another
    environment, nor do I want the code to be much more complicated than with a
    hardcoded location. The web service methods and classes are identical for
    all three environments, so I could let VS.NET talk to the development web
    service for figuring out class definitions etc. (I just want the actual
    communication when the web app is in use to be to the web service specified
    by each environment).

    Hope I made it clear to you what I'm trying to figure out :)

    Thanks!


    Regards,
    Nils Magnus Englund
    Nils Magnus Englund, Feb 21, 2005
    #1
    1. Advertising

  2. Nils Magnus Englund

    Jimmy Tharpe Guest

    > Is it possible to let the web services location be set in e.g. Web.config?

    The location is simply wherever you copy it to...

    > I
    > don't want to recompile the web application every time I move it to

    another
    > environment,


    Why do you think you would have to?

    -Jimmy
    Jimmy Tharpe, Feb 21, 2005
    #2
    1. Advertising

  3. Nils Magnus Englund

    Ollie Riches Guest

    In visual studio change the property 'URL Behavior' of the web service
    reference from 'static' to 'dynamic' this will automatically add an entry to
    your web config for you


    --
    HTH

    Ollie Riches
    http://www.phoneanalyser.net

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a programmer
    helping programmers.

    "Nils Magnus Englund" <> wrote in message
    news:...
    > Hi,
    >
    > I have a production, test and development environment for my web

    application
    > and a web service (The test web application connects to the test web
    > service, and so on).
    >
    > Is it possible to let the web services location be set in e.g. Web.config?

    I
    > don't want to recompile the web application every time I move it to

    another
    > environment, nor do I want the code to be much more complicated than with

    a
    > hardcoded location. The web service methods and classes are identical for
    > all three environments, so I could let VS.NET talk to the development web
    > service for figuring out class definitions etc. (I just want the actual
    > communication when the web app is in use to be to the web service

    specified
    > by each environment).
    >
    > Hope I made it clear to you what I'm trying to figure out :)
    >
    > Thanks!
    >
    >
    > Regards,
    > Nils Magnus Englund
    >
    >
    Ollie Riches, Feb 21, 2005
    #3
  4. Something along the lines of:

    dim ws as new myWebService

    ws.url = "http://999.999.999.999/My_Web_Service/Service1.asmx"

    You could store the IP address in the web.config and just read it in before
    setting the ws.url.

    Hope this helps
    Chris.

    "Nils Magnus Englund" wrote:

    > Hi,
    >
    > I have a production, test and development environment for my web application
    > and a web service (The test web application connects to the test web
    > service, and so on).
    >
    > Is it possible to let the web services location be set in e.g. Web.config? I
    > don't want to recompile the web application every time I move it to another
    > environment, nor do I want the code to be much more complicated than with a
    > hardcoded location. The web service methods and classes are identical for
    > all three environments, so I could let VS.NET talk to the development web
    > service for figuring out class definitions etc. (I just want the actual
    > communication when the web app is in use to be to the web service specified
    > by each environment).
    >
    > Hope I made it clear to you what I'm trying to figure out :)
    >
    > Thanks!
    >
    >
    > Regards,
    > Nils Magnus Englund
    >
    >
    >
    =?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=, Feb 21, 2005
    #4
  5. Hi Jimmy,

    Thank you for your reply, but I'm afraid you misunderstood - although I can
    place the web service wherever I want to, I need to somehow be able to refer
    the web application to the web service. How can I tell the web application
    the location of the web service? One method is by hardcoding it into the
    solution, but I wanted to do it dynamically, so I didn't have to recompile
    the solution when changing the web services hardcoded location.


    Regards,
    Nils Magnus Englund



    "Jimmy Tharpe" <> wrote in message
    news:...
    >> Is it possible to let the web services location be set in e.g.
    >> Web.config?

    >
    > The location is simply wherever you copy it to...
    >
    >> I
    >> don't want to recompile the web application every time I move it to

    > another
    >> environment,

    >
    > Why do you think you would have to?
    >
    > -Jimmy
    >
    >
    Nils Magnus Englund, Feb 21, 2005
    #5
  6. Hi Chris, and thanks for your reply.

    I think I indeed could do that, but that wouldn't let Visual Studio
    automatically make the classes and return types I need to fetch data from
    the web methods. It would however work great if I only used basic .NET types
    for the web application <> web service communication.


    Regards,
    Nils Magnus Englund


    "Chris Podmore" <> wrote in message
    news:...
    > Something along the lines of:
    >
    > dim ws as new myWebService
    >
    > ws.url = "http://999.999.999.999/My_Web_Service/Service1.asmx"
    >
    > You could store the IP address in the web.config and just read it in
    > before
    > setting the ws.url.
    >
    > Hope this helps
    > Chris.
    >
    > "Nils Magnus Englund" wrote:
    >
    >> Hi,
    >>
    >> I have a production, test and development environment for my web
    >> application
    >> and a web service (The test web application connects to the test web
    >> service, and so on).
    >>
    >> Is it possible to let the web services location be set in e.g.
    >> Web.config? I
    >> don't want to recompile the web application every time I move it to
    >> another
    >> environment, nor do I want the code to be much more complicated than with
    >> a
    >> hardcoded location. The web service methods and classes are identical for
    >> all three environments, so I could let VS.NET talk to the development web
    >> service for figuring out class definitions etc. (I just want the actual
    >> communication when the web app is in use to be to the web service
    >> specified
    >> by each environment).
    >>
    >> Hope I made it clear to you what I'm trying to figure out :)
    >>
    >> Thanks!
    >>
    >>
    >> Regards,
    >> Nils Magnus Englund
    >>
    >>
    >>
    Nils Magnus Englund, Feb 21, 2005
    #6
  7. Hi Ollie,

    Thank you! I feel slightly embarassed for not figuring that out by myself ;)
    That was exactly the kind of functionality I was looking (and hoping) for.


    Regards,
    Nils Magnus Englund


    "Ollie Riches" <> wrote in message
    news:...
    > In visual studio change the property 'URL Behavior' of the web service
    > reference from 'static' to 'dynamic' this will automatically add an entry
    > to
    > your web config for you
    >
    >
    > --
    > HTH
    >
    > Ollie Riches
    > http://www.phoneanalyser.net
    >
    > Disclaimer: Opinions expressed in this forum are my own, and not
    > representative of my employer.
    > I do not answer questions on behalf of my employer. I'm just a programmer
    > helping programmers.
    >
    > "Nils Magnus Englund" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> I have a production, test and development environment for my web

    > application
    >> and a web service (The test web application connects to the test web
    >> service, and so on).
    >>
    >> Is it possible to let the web services location be set in e.g.
    >> Web.config?

    > I
    >> don't want to recompile the web application every time I move it to

    > another
    >> environment, nor do I want the code to be much more complicated than with

    > a
    >> hardcoded location. The web service methods and classes are identical for
    >> all three environments, so I could let VS.NET talk to the development web
    >> service for figuring out class definitions etc. (I just want the actual
    >> communication when the web app is in use to be to the web service

    > specified
    >> by each environment).
    >>
    >> Hope I made it clear to you what I'm trying to figure out :)
    >>
    >> Thanks!
    >>
    >>
    >> Regards,
    >> Nils Magnus Englund
    >>
    >>

    >
    >
    Nils Magnus Englund, Feb 21, 2005
    #7
  8. I don't understand what you mean that it would work great only if you used
    basic .NET types. Changing the URL doesn't affect what the web service can
    return. All it's doing is changing the location of the web service which is
    what I thought you wanted to do. Did I miss something?

    Chris.

    "Nils Magnus Englund" wrote:

    > Hi Chris, and thanks for your reply.
    >
    > I think I indeed could do that, but that wouldn't let Visual Studio
    > automatically make the classes and return types I need to fetch data from
    > the web methods. It would however work great if I only used basic .NET types
    > for the web application <> web service communication.
    >
    >
    > Regards,
    > Nils Magnus Englund
    >
    >
    > "Chris Podmore" <> wrote in message
    > news:...
    > > Something along the lines of:
    > >
    > > dim ws as new myWebService
    > >
    > > ws.url = "http://999.999.999.999/My_Web_Service/Service1.asmx"
    > >
    > > You could store the IP address in the web.config and just read it in
    > > before
    > > setting the ws.url.
    > >
    > > Hope this helps
    > > Chris.
    > >
    > > "Nils Magnus Englund" wrote:
    > >
    > >> Hi,
    > >>
    > >> I have a production, test and development environment for my web
    > >> application
    > >> and a web service (The test web application connects to the test web
    > >> service, and so on).
    > >>
    > >> Is it possible to let the web services location be set in e.g.
    > >> Web.config? I
    > >> don't want to recompile the web application every time I move it to
    > >> another
    > >> environment, nor do I want the code to be much more complicated than with
    > >> a
    > >> hardcoded location. The web service methods and classes are identical for
    > >> all three environments, so I could let VS.NET talk to the development web
    > >> service for figuring out class definitions etc. (I just want the actual
    > >> communication when the web app is in use to be to the web service
    > >> specified
    > >> by each environment).
    > >>
    > >> Hope I made it clear to you what I'm trying to figure out :)
    > >>
    > >> Thanks!
    > >>
    > >>
    > >> Regards,
    > >> Nils Magnus Englund
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=, Feb 21, 2005
    #8
  9. Hi Chris,

    No, sorry, I missed something :) I thought you meant instantiating a basic
    web service, not my own web service (missed the crucial _my_WebService
    definition). Your method would work great as well! Thanks a lot :)


    Regards,
    Nils Magnus Englund


    "Chris Podmore" <> wrote in message
    news:...
    >I don't understand what you mean that it would work great only if you used
    > basic .NET types. Changing the URL doesn't affect what the web service can
    > return. All it's doing is changing the location of the web service which
    > is
    > what I thought you wanted to do. Did I miss something?
    >
    > Chris.
    >
    > "Nils Magnus Englund" wrote:
    >
    >> Hi Chris, and thanks for your reply.
    >>
    >> I think I indeed could do that, but that wouldn't let Visual Studio
    >> automatically make the classes and return types I need to fetch data from
    >> the web methods. It would however work great if I only used basic .NET
    >> types
    >> for the web application <> web service communication.
    >>
    >>
    >> Regards,
    >> Nils Magnus Englund
    >>
    >>
    >> "Chris Podmore" <> wrote in message
    >> news:...
    >> > Something along the lines of:
    >> >
    >> > dim ws as new myWebService
    >> >
    >> > ws.url = "http://999.999.999.999/My_Web_Service/Service1.asmx"
    >> >
    >> > You could store the IP address in the web.config and just read it in
    >> > before
    >> > setting the ws.url.
    >> >
    >> > Hope this helps
    >> > Chris.
    >> >
    >> > "Nils Magnus Englund" wrote:
    >> >
    >> >> Hi,
    >> >>
    >> >> I have a production, test and development environment for my web
    >> >> application
    >> >> and a web service (The test web application connects to the test web
    >> >> service, and so on).
    >> >>
    >> >> Is it possible to let the web services location be set in e.g.
    >> >> Web.config? I
    >> >> don't want to recompile the web application every time I move it to
    >> >> another
    >> >> environment, nor do I want the code to be much more complicated than
    >> >> with
    >> >> a
    >> >> hardcoded location. The web service methods and classes are identical
    >> >> for
    >> >> all three environments, so I could let VS.NET talk to the development
    >> >> web
    >> >> service for figuring out class definitions etc. (I just want the
    >> >> actual
    >> >> communication when the web app is in use to be to the web service
    >> >> specified
    >> >> by each environment).
    >> >>
    >> >> Hope I made it clear to you what I'm trying to figure out :)
    >> >>
    >> >> Thanks!
    >> >>
    >> >>
    >> >> Regards,
    >> >> Nils Magnus Englund
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    Nils Magnus Englund, Feb 21, 2005
    #9
    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. Replies:
    5
    Views:
    442
    Juan T. Llibre
    Oct 11, 2005
  2. Luke Dalessandro
    Replies:
    0
    Views:
    585
    Luke Dalessandro
    Jan 15, 2006
  3. zxo102
    Replies:
    0
    Views:
    396
    zxo102
    Aug 1, 2006
  4. Leo Violette
    Replies:
    0
    Views:
    993
    Leo Violette
    Apr 17, 2009
  5. saiho.yuen
    Replies:
    3
    Views:
    395
    kaeli
    Sep 14, 2004
Loading...

Share This Page