Asynchronous Web Services

If a web service you are designing exposes operations that may be long-running, you should design the interface of your web service such that clients do not have to wait in a blocked state for the long-running operations to complete. You do this by making your web service asynchronous. In your design, you provide one or more methods that accept requests from clients but that return quickly. You also provide a mechanism for the client to obtain the results of the long-running operation when the results are ready.

It's important to distinguish between an asynchronous web service and an asynchronous method (a method that always returns immediately, and always returns void). A web service may be asynchronous without using asynchronous methods. An example is a web service that provides a synchronous request operation that returns an acknowledgement but not the result, and later calls a synchronous callback that sends the result and receives an acknowledgement from the client. Both the method and the callback are synchronous, but the web service is asynchronous. To learn more about asynchronous methods and callbacks, see Asynchronous Methods.

There are two ways to design an asynchronous web service:

- Implement methods that initiate requests and callbacks to send results.
  To learn more about callbacks, see Using Callbacks to Notify Clients of Events.

- Implement methods that initiate requests and additional methods that return request status ("pending" or "complete"). The second approach is referred to as a polling interface.
  To learn more about implementing a polling interface, see Using Polling as an Alternative to Callbacks.

You may want to implement both approaches in your web service. Doing so would provide the convenience of callbacks to those clients who can handle them, and a polling interface for clients who cannot accept callbacks.

Related Topics

Building Web Services with WebLogic Workshop

Using Asynchrony to Enable Long-Running Operations

Maintaining State with Conversations