Chapter 11: Implementing OneWay and Asynchronous Operations


image from book Download CD Content

Overview

After completing this chapter, you will be able to:

  • Explain the behavior of OneWay operations, and how they are impacted by service behavior and binding properties.

  • Implement OneWay operations in a WCF service, and invoke them from a WCF client application.

  • Implement asynchronous operations in a WCF service, and invoke operations asynchronously in a WCF client application.

  • Explain the difference between invoking an operation asynchronously and implementing an operation that supports asynchronous execution.

  • Use a message queue to send requests to a service asynchronously.

WCF client applications and services frequently follow the request/response messaging pattern for performing operations; the client application issues a request and then waits patiently while the message crosses the network, the service receives and processes the message, the service generates a reply, and the reply wends its way back across the network to the client application. If the client application does not require the service to send a response, then waiting for one is a waste of time and can impact the responsiveness of the client application. In this situation, you might find that a OneWay operation can improve performance of the client application.

If the client application does require a response but can safely perform other tasks while waiting for this response, then you should use asynchronous method invocation. This technique enables the client application to send a request and then continue execution. When a reply message arrives from the service, a separate thread in the client application handles the response.

OneWay operations and asynchronous operations both require that the client application and the service are running at the same time. If this is not the case, then you should consider using message queues as the transport medium between the client application and the service. A message queue can provide durable storage for messages. However, you must design client applications and services carefully if you are planning on using message queues, as the request/response messaging pattern is not appropriate in this case.

In this chapter, you will look in detail at these three options for invoking operations in a WCF service and maximizing the scope for parallelism in your applications.

Note 

It is also possible for a client to provide a callback method for a service. The service can send a message that invokes this method. WCF client applications and services can use this mechanism to implement events, enabling the service to notify a client application of some significant occurrence. You will examine this feature in more detail in Chapter 14, “Using a Callback Contract to Publish and Subscribe to Events.”




Microsoft Windows Communication Foundation Step by Step
Microsoft Windows Communication Foundation Step by Step (Step By Step Developer Series)
ISBN: 0735623368
EAN: 2147483647
Year: 2007
Pages: 105
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net