I need opinions regarding Web Service Namespace usage and/or suggestions
regarding how to handle deployment.
Our web service application will exist in two different domains and is
likely to exist in multiple domains. There is a prevailing opinion here at
my office that the Web Service Namespace should match the domain where it is
installed. From what I have read, the Namespace simply needs to be unique
and does not necessarily need to match the domain name where the service
resides. Regardless, the decision has been made that the Namespace is to
match the domain it is installed.
Given that edict, our department has directed me to figure out how to
configure the Namespace dependent upon its installed domain name. For
example, they would like to put an entry into the Web.config file that would
determine the Namespace for the Web Service. Ideally, the Web Service
application could read the Web.config file to obtain the Namespace value and
assign this to the WebService() attribute.
[WebService(Namespace="http://www.mydomain.com/myws")]
[WebService(Namespace="http://www.myotherdomain.com/myws")]
Despite the edict, I have no idea how to do this. As far as I can tell, the
Attribute for the Namespace is hardcoded, it is a constant that is compiled
into the service, it is static and unchanging once the application is built.
I did try to assign a variable to the attribute—from a value which I tried to
retrieve from the Web.config file with the following statement:
[WebService(Namespace=ConfigurationSettings.AppSett ings["ServiceNamespace"])].
However (and not too surprisingly), I received an error from Visual Studio
that it expected a constant.
My questions are:
1. Is there anyway to base the namespace name upon a value that is only
defined at run time?
2. Are there any other suggestions regarding how to handle this issue?
The only other way I can think of handling this is to make separate builds,
one for each domain it is installed, which management has ruled is out of the
question. Any help regarding this matter will be greatly appreciated.
Thanks.
--Charles Leonard