2

In WCF can you re-use endpoint behaviors, service behaviors and bindings? Or must each service / endpoint have distinct ones even if they are the same except for their ID.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Matt
  • 25,943
  • 66
  • 198
  • 303
  • You're not "re-using" them as such because in your config they're not an object, they're simply a definition. – slugster Aug 03 '18 at 01:54

1 Answers1

2

You can reuse them - just specify the appropriate one(s) (via the name you gave them in their section) for the endpoints in question.

For example, assume you have a service behavior named "MyServiceBehavior", a wsHttpBinding named "MyWsHttpBinding" and an endpoint behavior named "MyEndpointBehavior".

For the service behavior, you'd use the behaviorConfiguration attribute (behaviorConfiguration="MyServiceBehavior") in the <service> element.

For the binding and endpoint behavior, you'd use the bindingConfiguration attribute (bindingConfiguration="MyWsHttpBinding") and the behaviorConfiguration attribute (behaviorConfiguration="MyEndpointBehavior") of the <endpoint> element.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tim
  • 28,212
  • 8
  • 63
  • 76