Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

JAX-WS Async call

Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?

Ranch Hand
Posts: 2198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic