0

I am trying to figure out how to get an handle on the endpoints of the service host and modify their identity. I have endpoints defined in the config file but want to modify the endpoints programmatically depending on the environment (ex:QA, UAT, Prod)

Service is hosted on IIS6 and I am using a servicehostfactory to provide my extended servicehost class to IIS.

I am using opening event to get an handle on the endpoints that are already defined from the config file but can't figure out how to modify their identity. Is that even possible? Are endpoints are immutable after they are created?

If I can't modify the endpoints then is the "Opening" event of the servicehost is the correct event to add a service endpoint?

user507040
  • 11
  • 1

1 Answers1

2

ServiceHosts are not immutable until they are Opened. You can modify the description of an endpoint after calling AddServiceEndpoint.

When you say Opening event, do you mean you've subclassed ServiceHost and are overriding OnOpening? If so, that's a fine place to add endpoints.

Alternatively, if you're using your own ServiceHostFactory, you can just add your endpoint(s) after calling base.CreateServiceHost.

Jeff
  • 35,755
  • 15
  • 108
  • 220
  • Thank you for the response Jeff. Adding the endpoints after calling base.CreateServiceHost is a good idea. In my case I am not explicitly calling AddServiceEndpoint. I have my definitions in the config file and after they get defined by the clr I want to modify their identity depending on the environment. I want to make a minimum change with the code and I want all the rest of the configuration to be done by the clr via config file. Is this something that can be done or do I have to define them completely by coding? – user507040 Nov 14 '10 at 23:26