Currently we're using in code <System.Web.Services.WebService(Namespace:="https://ourservice/")>
to set the namespace, can this be done in web.config, instead? I've looked but can't find where?
VS2008, ASMX web service.
Currently we're using in code <System.Web.Services.WebService(Namespace:="https://ourservice/")>
to set the namespace, can this be done in web.config, instead? I've looked but can't find where?
VS2008, ASMX web service.
have you tried this?
<Services>
<asp:ServiceReference
path="https://ourservice" />
</Services>
another option may be to create pair in the web.config file and read that section using ConfigurationManager class.
<appSettings>
<add key="OurService"
value="https://ourservice"/>
</appSettings>
I don't think you can put it in the config file (though I never bothered to check).
If you just want it stored at a central location, you can use always use a constant:
internal sealed class ServiceConstants {
internal const string Namespace = "urn:example.com/~coolest/service/ever";
}
[ServiceContract(Namespace=ServiceConstants.Namespace)]
[WebService(Namespace=ServiceConstants.Namespace)]
public sealed class MyService {}
The most important question hasn't been asked: why do you think you want to do this.
Most people who ask this question are under the impression that the namespace is related to the URL at which the service is deployed. They have nothing at all to do with each other. In fact, the namespace could be a URI like "urn:services.yourcompany.com", which is clearly not a location on the Internet.