Setting web service location dynamically

  • Thread starter Nils Magnus Englund
  • Start date
N

Nils Magnus Englund

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
 
J

Jimmy Tharpe

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
 
O

Ollie Riches

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

Nils Magnus Englund

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
 
N

Nils Magnus Englund

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
 
N

Nils Magnus Englund

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
 
G

Guest

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

Nils Magnus Englund

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
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,232
Latest member
DorotheaDo

Latest Threads

Top