URL Behaviour

C

Chris

We've added a web service to our application. I've set the "URL Behaviour"
property to dynamic.

The put the following key in our web.config file:-
<add key="MyApp.MyWebService.Common"
value="http://localhost/Webservice/Webservice.asmx"/>

This works fine, but I would like to specify a relative URL. If I can't
specify a relative URL then our customers will have to manually edit the
web.config file which is not ideal. I the URL was relative to our
application then where ever the application is installed to the web service
will always be accessible.

Is this possible using any means or are there any other suggestions?

Thanks,
Chris
 
K

Keenan Newton

It is possible to fingle the URL. on your Web Service proxy class the
URL is a public property so you can change it. However I strongly
recommend not trying to set the IRL relative to the application for the
simnple fact what if you customer wants to use 2 different servers(one
for the web application and one for the web service)? I would assume
you customers would only have to modify the web.config one time, but
also remebr the web config is no more thanh an xml file. You could
build a utlity to set certain properties (attributes) of your
application to what ever the client needs. Hence thewy don't need to
modify the web.config file directly. I would leave the application as
flexible as possible when it comes to configuration.
 
C

Chris

Hi,

Thanks for the information. I found out how to change the URL of the web
service with code.

To give us complete flexibility i've done the following:-
1. Set the Web Service to be dynamic. This add the entry in the web.config
for the location of the web service on my machine
2. When we install our product I change the value in the web.config file to
say "Default".
3. When our application runs, it checks this value stored in the we.config.
If it is still set to "Default" the application will change the URL with
code to a path relative to our application. If the value has been changed
to anything other than "Default" then the customer has manually edited the
web.config because they want to point to the web service on a different
server (as in your example).

I think this will give the user the best choice possible. Firstly for most
of our users who will not want to change this there will be no manual
configuration. For the more advanced users it is a flexible as needed.

Can you see any flaws with this?

Thanks,
Chris
 
K

Keenan Newton

No it looks decent. make sure you don't modify the base implementation
and that you inherit from the web proxy class and make your changes in
the inherited calss. this way you can always regen the web service
proxy "base" class that .Net gens without losing your changes.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top