File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes JAX-WS Async call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "JAX-WS Async call" Watch "JAX-WS Async call" New topic

JAX-WS Async call

karthikeyan kumar

Joined: May 19, 2009
Posts: 19
I have a question to interpret the following statement in the below link

Using an asynchronous message exchange

By default, asynchronous client invocations do not have asynchronous behavior of the message exchange pattern on the wire. The programming model is asynchronous; however, the exchange of request or response messages with the server is not asynchronous. To use an asynchronous message exchange, the property must be set on the client request context with a boolean value of true. When this property is enabled, the messages exchanged between the client and server are different from messages exchanged synchronously. With an asynchronous exchange, the request and response messages have WS-Addressing headers added that provide additional routing information for the messages. Another major difference between asynchronous and synchronous message exchange is that the response is delivered to an asynchronous listener that then delivers that response back to the client. For asynchronous exchanges, there is no timeout that is sent to notify the client to stop listening for a response. To force the client to stop waiting for a response, issue a Response.cancel() method on the object returned from a polling invocation or a Future.cancel() method on the object returned from a callback invocation. The cancel response does not affect the server when processing a request.

My question here is only when we set the "mep" property the client then starts the local http server connection and waiting for the reponse from the server. But if we did not set this flag then either your actual client will be waiting (Polling method) or the listener might be waiting (call back method).

1) Use polling method and then call cancel() method will result in cancelling all the waiting threads on the client side to receive the reponse
2) set the mep flag but still call the cancel method will result terminating the above the new Http connection

the point i want to make sure is we use async call to "call and return" and i dont want any threads to wait on the client side expecting the results based on my requirement.

Can any of you thought about this ?

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
If you want a truly asynchronous web service with the service calling the client and the service generating some kind of result, here is what you can do:
1. Implement the service to insert the request into some kind of queue and then immediately return.
Example of queues are ApacheMQ, Java SE classes implementing the java.util.Queue interface, a JMS queue etc.
2. Implement a callback service on the client side.
The service server needs a way to tell the client that a result of the request submitted by the client is ready.
You can also use polling, in which case you do not need a callback service on the client side.
Best wishes!
I agree. Here's the link:
subject: JAX-WS Async call
It's not a secret anymore!