Endpoint添加到servicehost后可以修改吗?
我试图弄清楚如何获取服务主机端点的句柄并修改它们的身份。我在配置文件中定义了端点,但希望根据环境(例如:QA、UAT、Prod)以编程方式修改端点。
服务托管在 IIS6 上,我使用 servicehostfactory 向 IIS 提供扩展的 servicehost 类。
我正在使用打开事件来获取已从配置文件定义的端点的句柄,但无法弄清楚如何修改其身份。这可能吗?端点创建后是不可变的吗?
如果我无法修改端点,那么服务主机的“打开”事件是添加服务端点的正确事件吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ServiceHost 在打开之前并不是一成不变的。调用AddServiceEndpoint后,您可以修改端点的描述信息。
当您说 Opening 事件时,您的意思是您已经子类化了 ServiceHost 并重写了 OnOpening 吗?如果是这样,那么这是添加端点的好地方。
或者,如果您使用自己的 ServiceHostFactory,则可以在调用 base.CreateServiceHost 之后添加端点。
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.