.net - WCF service multiple behaviors -
i've done wcf, it's been while, , i've never had configure service scratch.
apparently, while can have 1 behavior configuration, it's possible attach multiple behaviors 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:
- is possible attach multiple service behaviors service? ... or, matter, multiple endpoint behaviors? or limited @ 1 of each? that's not clear me snippet (which closest thing answer i've turned far in search).
- is possible via configuration (rather programmatically)?
you create named behavior list behaviors sub-items of 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 visual studio install under name "service configuration editor") can edit , configure .config files , create complex bindings 1 above easily.
Comments
Post a Comment