开发者

How to add a default endpoint behaviors to all services

I'm attempting to add an endpoint behavior to all services of a host.开发者_JS百科

So for example, I have a couple of .svc ServiceHost declarations and I want to know how I would be able to configure this via Web.config.

Any ideas? Thanks.


Create custom class derived from ServiceHost and custom class derived from ServiceHostFactory. In your custom ServiceHost implementation add needed behaviors. Here you have example.


Untested, but see if this helps -

foreach (var endPoint in mySvcHost.Description.Endpoints)
{
    endPoint.Behaviors.Add(new MyBehavior());
}


It's untested but I think if you add an EndpointBehavior with no name to the Advanced->Endpoint Behavior (in the WCF config tool), then it's done for all service endpoints (unless overriden).

The same thing works for the Service Behaviors (that's what I'm using so I know that works).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜