How can we improve WCF?

Alternative to statics (OperationContext.Current et al)

Mainly for testability - it should be able to inject the context into your service instance.

52 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Lars WilhelmsenLars Wilhelmsen shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Matt Connew (msft)Matt Connew (msft) commented  ·   ·  Flag as inappropriate

        There are multiple existing extensibility points to achieve this depending on what you wish to modify. You don't want to set a property in the context too early and have WCF overwrite your changes later on in the pipeline. Because of this, the safest extensibility point to use is the last one in the pipe, IOperationInvoker. You can create a simple wrapping invoker which modifies the current OperationContext any way you wish and then delegates actually calling your operation to the existing invoker. A simple example of a custom invoker complete with boilerplate behavior can be found in Carlos Figueira's blog here: https://blogs.msdn.microsoft.com/carlosfigueira/2011/05/16/wcf-extensibility-ioperationinvoker/

      • Hasan TurksoyHasan Turksoy commented  ·   ·  Flag as inappropriate

        +1 for testability... for instance injecting different identity information into SecurityContext would be a good way to test windows authenticated services.

      Feedback and Knowledge Base