Chapter 5. Operations

The classic object- or component-oriented programming models offered only a single way for clients to call a method: the client would issue a call, block while the call was in progress, and continue executing once the method returned. Any other calling model had to be handcrafted, often incurring productivity and quality penalties. While WCF supports this classic invocation model, it also provides built-in support for additional operation types: one-way calls for fire-and-forget operations, duplex callbacks for allowing the service to call back to the client, and streaming to allow the client or the service to handle large payloads. In general, the type of operation used is part of the service contract and is an intrinsic part of the service design. The operation type may even place some constraints on the allowed bindings. Consequently, clients and services should be designed from the ground up with the operation type in mind, and you cannot switch easily between the various operation types. This chapter is dedicated to the various ways of invoking WCF operations and the related design guidelines.1 Two other ways of invoking operations—asynchronously and queued—are addressed in subsequent chapters.

Request-Reply Operations

All the samples in the previous chapters included contracts whose operations were of the type known as request-reply. As the name implies, in these operations, the client issues a request in the form of a message and blocks until it gets ...

Get Programming WCF Services, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.