Invoking Web Services Asynchronously 3-29
int result = callbackHandler.getResponse.getReturn; To implement an asynchronous polling mechanism:
1.
Instantiate the AddNumbersService Web service and call the asynchronous version of the Web service method, addNumbersAsync.
ResponseAddNumbersResponse addNumbersResp = port.AddNumbersAsyncnumber1, number2;
2.
Sleep until a message is received. while addNumbersResp.isDone {
Thread.sleep100;
3.
Poll for a response. AddNumbersResponse reply = addNumbersResp.get;
3.8 Propagating Request Context to the Response
WebLogic Server provides a powerful facility that enables you to attach your business context—for example, a business-level message ID—to the request message and access
it when the response is returned, regardless of what the request and response messages convey over the wire. For example, you may have a business-level message
ID that will not otherwise be available in the response message. By propagating this information with the message, you can access it when the response message is
returned.
Web service clients can store any request message context property, as long as it is Serializable. Message context properties can be stored as part of the
weblogic.wsee.jaxws.JAXWSProperties.PERSISTENT_CONTEXT Map property and retrieved after the response message is returned.
The following example shows how to use the PERSISTENT_CONTEXT Map property to define and set a message context property.
Example 3–3 Setting Message Context Properties
import weblogic.wsee.jaxws.JAXWSProperties; . . .
MyClientPort port = myService.getPort; MapString, Serializable clientPersistProps =
port.getRequestContext.getJAXWSProperties.PERSISTENT_CONTEXT; Serializable obj = my_property;
clientPersistProps.putMyProperty, obj;
port.myOperationAsyncargs, new AsyncHandlerMyOperationResponse { public void handleResponseResponseMyOperationResponse res {
try { Get the actual response
MyOperationResponse response = res.get.getReturn;
Get the property stored when making request. Note, this property did not get passed over the wire with the reuqest. The Web services runtime stores it.
MapString, Serializable clientPersistProps = res.getContext.getJAXWSProperties.PERSISTENT_CONTEXT;
Serializable obj = clientPersistProps.getMyProperty; Do something with MyProperty
} catch Exception e {
3-30 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
Error handling }
} };
...
3.9 Monitoring Asynchronous Web Service Invocation
You can monitor runtime information for clients that invoke Web services asynchronously, such as number of invocations, errors, faults, and so on, using the
Administration Console. To monitor Web service clients, click on the Deployments node in the left pane and, in the Deployments table that appears in the right pane,
locate the Enterprise application in which the Web service client is packaged. Expand the application by clicking the + node and click on the application module within
which the Web service client is located. Click the Monitoring tab, then click the Web Service Clients
tab. If you use the MakeConnection transport protocol, you can monitor the
MakeConnection anonymous endpoints for a Web service or client. For each anonymous endpoint, runtime monitoring information is displayed, such as the
number of messages received, the number of messages pending, and so on.
You can customize the information that is shown in the table by clicking Customize this table
. To monitor MakeConnection anonymous endpoints for a Web service, click on the
Deployments
node in the left pane and, in the Deployments table that appears in the right pane, locate the Enterprise application in which the Web service is packaged.
Expand the application by clicking the + node; the Web services in the application are listed under the Web Services category. Click on the name of the Web service and
select Monitoring Ports Make Connection.
To monitor MakeConnection anonymous endpoints for a Web service client, click on the Deployments node in the left pane and, in the Deployments table that appears in
the right pane, locate the Enterprise application in which the Web service client is packaged. Expand the application by clicking the + node and click on the application
module within which the Web service client is located. Click the Monitoring tab, then click the Web Service Clients tab. Then click Monitoring Servers Make
Connection
.
3.10 Clustering Considerations for Asynchronous Web Service Messaging