Invoking Web Services Asynchronously 3-31
Figure 3–3 Clustering Scenario Resulting in an Error
In the scenario shown in the previous figure:
■
A two-node cluster hosts the client application; the nodes are named Server1 and Server2. The cluster has a simple load-balancing front-end proxy.
■
The client application is a Web application called ClientWebApp which is deployed homogeneously to the cluster. In other words, the Web application runs
on both member servers in the cluster.
■
External clients of the ClientWebApp application make requests through the cluster front-end address.
Now consider the following sequence:
1. An external client requests a page from ClientWebApp via the cluster front-end.
2. The cluster front-end load balances the page request and sends it to the
ClientWebApp on Server1.
3. ClientWebApp on Server1 creates an instance of a Web service client,
BackendServiceClient, to communicate with its back-end service, BackendService. The creation of BackendServiceClient causes an asynchronous response endpoint
to be published to receive asynchronous responses whenever BackendServiceClient is used to make an asynchronous request.
4. ClientWebApp on Server1 calls
BackendServiceClient.doSomethingAsync to perform an operation on the backend service. The address of the asynchronous response endpoint is
included in the ReplyTo address. This address starts with the address of the cluster front end, and not the address of Server1.
3-32 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
5.
The cluster receives the response to the doSomething operation.
6.
The cluster load balances the message, this time to Server2.
7.
The message delivery fails because there is no asynchronous response endpoint on Server2 to receive the response.
You can use one of the following to resolve this problem:
■
Use a SOAP-aware cluster front-end proxy plug-in, such as WebLogic Server HttpClusterServlet. For more information, see Configure Proxy Plug-ins in Using
Clusters for Oracle WebLogic Server. This option may not be feasible, for example if your company has standardized on a cluster front-end technology.
■
Ensure that all member servers in a cluster publish an asynchronous response endpoint so that the asynchronous response messages can be delivered to any
member server and optionally forwarded to the correct server via in-place cluster routing.
To implement the second option, it is recommended that you define a singleton port instance and initialize it when the client container initializes upon deployment. For
an example illustrating the recommended method for initializing the asynchronous response endpoint in a cluster, see
Example 2–2, Asynchronous Web Service Client Best Practices Example
.
Note: You may choose to initialize the endpoint in different ways
depending on the container type. For example, if the client is hosted in a Web service, a method on the Web service container could be
annotated with PostConstruct and that method could initialize the singleton port. In an EJB container, you could use the
ejbCreate method as the trigger point for creating the singleton port.
4
Roadmap for Developing Reliable Web Services and Clients 4-1