• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about Invoking a Web Service Asynchronously

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I head read a tutorial about invoking a Web Service asynchronously, and seen there are two approaches to accomplish this from an API point of view :

  • Polling
  • Callback


  • As a programmatic [API] point of view, this is well understood, but my question is about the Socket layer of the asynchronous web service invocation.

    My imagination for it, is that, a client sends a request, and the server (may) take(s) a lot of time to process the request. In this time, the socket connection is not closed, but when the server finishes processing, it sends the response back to the client over the same socket connection, where the whatever JAX-WS classes catch it and passes it to the Callback classes.

    Is my understanding of asynchronous web services correct ??

    Thanks in advance.
     
    Ranch Hand
    Posts: 2198
    1
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi!
    This matter is further complicated by the fact that JAX-WS has an asynchronous client model, which is what you described with your "imagination".
    To enumerate the available options:
  • Synchronous invocation

  • The invocation do not return until the operation has finished processing.

  • Asynchronous one-way invocation

  • Also called "fire-and-forget". The request is sent to the web service but no response will be given. The client can continue to execute despite the request not having finished being processed, because the client does not need to wait for a result. When using a HTTP binding, there will be a confirmation that the request has reached the server, which the client must wait for.

  • Asynchronous client

  • The web service is still a regular, synchronous web service. The difference is on the client side, where a request is sent and and a special thread is dispatched to await the result. The client can learn about the result either by a special object being called back when a result is available or by polling a response-object to examine if the operation has completed an a response is available.
    In both cases, a timeout can be specified that limits the time the client waits for a result.
    The client will never be called back, or need to poll, the web service - everything regarding the asynchronous invocation is taken care of on the client side.

  • Asynchronous web service.

  • The web service is asynchronous and supplies an operation with which clients can submit a task to the service.
    There are two different ways by which clients can obtain the result of a task:
    1. Polling.
    The web service supplies another operation which the clients can invoke to check if a task has been processed, supplying a correlation identifier of some kind that tells the service which task the client wants to know about.
    2. Callback.
    The clients must provide a service which will be invoked by the web service to which the client submitted a task when the task has been processed.

    A lot of text , hope things are more clear!
    Best wishes!

     
    Khaled Mahmoud
    Ranch Hand
    Posts: 361
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Ivan for the wonderful explanation . You saved me a lot of time searching and reading.

    So most the asynchronous Web Service implementation lies on the developer for the web service.

     
    Ranch Hand
    Posts: 254
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi All,

    I'm a beginner for web-service.
    @Ivan Krizsan Nice explanation. Can you give a sample example for each web-service. I found explanation in google search but not a proper code.

    Thanks:
    Ramakrishna K.C
     
    Ranch Hand
    Posts: 1376
    Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Ivan for this explanation.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic