Reputation: 2272
I've done some WCF, but it's been a while, and I've never had to configure a service from scratch.
Apparently, while you can only have one behavior configuration, it's possible to attach multiple behaviors to a WCF service:
ServiceHost serviceHost = new ServiceHost(typeof(Services.FooService), ServiceEndpointUri);
WebHttpBinding binding = new WebHttpBinding();
ServiceEndpoint sep = serviceHost.AddServiceEndpoint(typeof(Contracts.IFooService), binding, string.Empty);
sep.Behaviors.Add(new WebHttpBehavior());
sep.Behaviors.Add(new MyCustomEndpointBehavior());
I'm wondering:
Upvotes: 0
Views: 2344
Reputation: 127603
You just create a named behavior then list your behaviors as sub-items of your named behavior.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MyExampleBehavior">
<webHttp />
<MyCustomEndpointBehavior />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Example.Endpoints.MyEndpoint">
<endpoint behaviorConfiguration="MyExampleBehavior" .../>
</service>
</services>
using SvcConfigEditor.exe
(which should have been included with your visual studio install under the name "Service Configuration Editor") it can help you edit and configure .config files and create complex bindings the one above easily.
Upvotes: 2