Skip to Content
Programming WCF Services, 2nd Edition
book

Programming WCF Services, 2nd Edition

by Juval Lowy
November 2008
Intermediate to advanced
784 pages
23h 28m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services, 2nd Edition

Intercepting Service Operations

Recall from Chapter 1 that in the abstract, all WCF does when intercepting calls is perform pre- and post-call operations. Adding custom steps to this interception mechanism is probably the most common way of extending WCF.

Every endpoint dispatcher has a reference to an interface called IOperationInvoker, defined as:

public interface IOperationInvoker
{
   object[] AllocateInputs(  );
   object Invoke(object instance,object[] inputs,out object[] outputs);

   //Asynchronous invocation methods
}

The dispatcher uses the Invoke( ) method to invoke the calls on the service instance. In providing for the invocation, IOperationInvoker is the right place to plug in your code. Specifically, assigning the dispatcher your implementation of IOperationInvoker will enable you to hook it in.

The Generic Invoker

The first step in implementing my generic interceptor framework was to provide an abstract implementation of IOperationInvoker that enables custom pre- and post-call steps, as shown in Example E-1.

Example E-1. The GenericInvoker class

public abstract class GenericInvoker : IOperationInvoker { readonly IOperationInvoker m_OldInvoker; public GenericInvoker(IOperationInvoker oldInvoker) { m_OldInvoker = oldInvoker; } public virtual object[] AllocateInputs( ) { return m_OldInvoker.AllocateInputs( ); } protected virtual void PreInvoke(object instance,object[] inputs) {} //Always called, even if operation had an exception protected virtual void PostInvoke(object instance,object ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming WCF Services

Programming WCF Services

Juval Lowy

Publisher Resources

ISBN: 9780596157210Supplemental ContentErrata