Overview of Asynchronous Web Service Invocation

3 Invoking Web Services Asynchronously 3-1 3 Invoking Web Services Asynchronously The following sections describe how to invoke Web services asynchronously: ■ Section 3.1, Overview of Asynchronous Web Service Invocation ■ Section 3.2, Steps to Invoke Web Services Asynchronously ■ Section 3.3, Configuring Your Servers for Asynchronous Web Service Invocation ■ Section 3.4, Building the Client Artifacts for Asynchronous Web Service Invocation ■ Section 3.5, Developing Scalable Asynchronous JAX-WS Clients Asynchronous Client Transport ■ Section 3.6, Using Asynchronous Web Service Clients From Behind a Firewall MakeConnection ■ Section 3.7, Using the JAX-WS Reference Implementation ■ Section 3.8, Propagating Request Context to the Response ■ Section 3.9, Monitoring Asynchronous Web Service Invocation ■ Section 3.10, Clustering Considerations for Asynchronous Web Service Messaging

3.1 Overview of Asynchronous Web Service Invocation

To support asynchronous Web services invocation, WebLogic Web services can use an asynchronous client programming model, asynchronous transport, or both. Table 3–1 provides a description and key benefits of the asynchronous client programming model and transport types, and introduces the configuration options available to support asynchronous Web service invocation. Note: See also Section 2, Roadmaps for Developing Web Service Clients . Note: The method of generating a WSDL for the asynchronous Web service containing two one-way operations defined as two portTypes—one for the asynchronous operation and one for the callback operation—is not supported in the current release. 3-2 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server Table 3–2 summarizes the transport types that WebLogic Server supports for invoking a Web service asynchronously or synchronously, if configured from a Web service client. Table 3–1 Support for Asynchronous Web Service Invocation Type Description Benefits Client programming model Describes the invocation semantics used to call a Web service operation: synchronous or asynchronous. When you invoke a Web service synchronously, the invoking client application waits for the response to return before it can continue with its work. In cases where the response returns immediately, this method of invoking the Web service might be adequate. However, because request processing can be delayed, it is often useful for the client application to continue its work and handle the response later on. By calling a Web service asynchronously, the client can continue its processing, without interruption, and be notified when the asynchronous response is returned. To support asynchronous invocation, you generate automatically an asynchronous flavor of each operation on a Web service port using the clientgen Ant task, as described later in Section 3.4, Building the Client Artifacts for Asynchronous Web Service Invocation. Then, you add methods in your client, including your business logic, that handle the asynchronous response or failures when it returns later on. Finally, to invoke a Web service asynchronously, rather than invoking the operation directly, you invoke the asynchronous flavor of the operation. For example, rather than invoking an operation called addNumbers directly, you would invoke addNumbersAsync instead. Asynchronous invocation enables Web service clients to initiate a request to a Web service, continue processing without blocking, and receive the response at some point in the future. Transport There are three transport types: asynchronous client transport, MakeConnection transport, and synchronous transport. For a comparison of each transport type, see Table 3–2 . Asynchronous client transport and MakeConnection transport deliver the following key benefits: ■ Improves fault tolerance in the event of network outages. ■ Enables servers to absorb more efficiently spikes in traffic. Configuration Configure Web service persistence and buffering optional to support asynchronous Web service invocation. For more information, see Section 3.3, Configuring Your Servers for Asynchronous Web Service Invocation. Benefits of configuring the Web service features include: ■ Persistence supports long running requests and provides the ability to survive server restarts. ■ Buffering enables all requests to a Web service to be handled asynchronously. Invoking Web Services Asynchronously 3-3 Table 3–2 Transport Types for Invoking Web Services Asynchronously Transport Types Description Asynchronous Client Transport Provides a scalable asynchronous client programming model through the use of an addressable client-side asynchronous response endpoint and WS-Addressing. Asynchronous client transport decouples the delivery of the response message from the initiating transport request used to send the request message. The response message is sent to the asynchronous response endpoint using a new connection originating from the Web service. The client correlates request and response messages through WS-Addressing headers. Asynchronous client transport provides improved fault tolerance and enables servers to better absorb spikes in server load. For details about using asynchronous client transport, see Section 3.5, Developing Scalable Asynchronous JAX-WS Clients Asynchronous Client Transport. Asynchronous client transport supports the following programming models: ■ Asynchronous and dispatch callback handling using one of the following methods: - Port-based asynchronous callback handler, AsyncClientHandlerFeature, described in Section 3.5.2, Developing the Asynchronous Handler Interface. This is recommended as a best practice when using asynchronous invocation due to its scalability and ability to survive a JVM restart. - Per-request asynchronous callback handler, as described in Section 3.7, Using the JAX-WS Reference Implementation. ■ Asynchronous polling, as described in Section 3.7, Using the JAX-WS Reference Implementation. ■ Synchronous invocation by enabling a flag, as described in Section 3.5.1.5, Configuring Asynchronous Client Transport for Synchronous Operations. 3-4 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server MakeConnection Transport Enables asynchronous Web service invocation from behind a firewall using Web Services MakeConnection 1.1 or 1.0. MakeConnection is a client polling mechanism that provides an alternative to asynchronous client transport. As with asynchronous client transport, MakeConnection enables the decoupling of the response message from the initiating transport request used to send the request message. However, unlike asynchronous client transport which requires an addressable asynchronous response endpoint to forward the response to, with MakeConnection typically the sender of the request message is non-addressable and unable to accept an incoming connection. For example, when the sender is located behind a firewall. MakeConnection transport provides improved fault tolerance and enables servers to better absorb spikes in server load. For details about MakeConnection transport, see Section 3.6, Using Asynchronous Web Service Clients From Behind a Firewall MakeConnection. MakeConnection transport is recommended as a best practice when using asynchronous invocation from behind a firewall due to its scalability and ability to survive a JVM restart. It supports the following programming models: ■ Asynchronous and dispatch callback handling using one of the following methods: - Port-based asynchronous callback handler, AsyncClientHandlerFeature, described in Section 3.5.2, Developing the Asynchronous Handler Interface . - Per-request asynchronous callback handler, as described in Section 3.7, Using the JAX-WS Reference Implementation ■ Asynchronous polling, as described in Section 3.7, Using the JAX-WS Reference Implementation . ■ Synchronous invocation by enabling a flag, as described in Section 3.6.2.4, Configuring MakeConnection as the Transport for Synchronous Methods . Use of MakeConnection transport with AsyncClientHandlerFeature is recommended as a best practice when using asynchronous invocation due to its scalability and ability to survive a JVM restart. Synchronous Transport Provides support for synchronous and asynchronous Web service invocation with very limited support for WS-Addressing. For details, see Section 3.7, Using the JAX-WS Reference Implementation . Synchronous transport is recommended when using synchronous invocation. It can be used for asynchronous invocation, as well, though this is not considered a best practice. It supports the following programming models: ■ Asynchronous and dispatch callback handling on a per request basis using the standard JAX-WS RI implementation, described in Section 3.7, Using the JAX-WS Reference Implementation . ■ Asynchronous polling, as described in Section 3.7, Using the JAX-WS Reference Implementation . ■ Synchronous invocation. Table 3–2 Cont. Transport Types for Invoking Web Services Asynchronously Transport Types Description Invoking Web Services Asynchronously 3-5

3.2 Steps to Invoke Web Services Asynchronously