Web Services Asynchronous

Web Services Asynchronous

Perhaps something very different and weird to see around is an asynchronous web services, but yes! This beast really exists, at least it’s possible to generate an asynchronous Web Services Client with some binding customization. The JAX-WS provides support for invoking a Web Services through an asynchronous client. This asynchronous calling support is provided in two models: Callback and Polling. In the Callback approach we (as the client) just have to wait for a call arrives with our response, and in the Polling approach we have to check once in a while whether our response is already available and  then get it.

Asynchronous communication is a feature controlled by WSDL binding customization in JAX-WS. The binding process is instrumented by a tag enableAsyncMapping for asynchrony when generating web service client artifacts. One option is to use an external standalone XML file for the WSDL binding customization. In addition to the external binding file approach, another option would be embed binding declarations directly into a WSDL document, and use this approach to customize the client. In our example, we are going to use the first option, an external XML binding file. Let’s dive into our sample.

THINKING AND DRAWING…

Well, nothing better than a clean blank paper sheet to help you think before execute something. It’s always a good idea have, at least, some sketches of what we are going to implement.

SYNCHRONOUS CALLING

Actually, I was in doubt about add this sketch regarding the synchronous calling of a Web Services, of course, this is so obvious for everybody (I think), but just not to be unfair with the synchronous calling and for the sake of comparison between all the the calling techniques, let’s add its drawing as well.

As mentioned before, there’s nothing new in Picture 1 below, the Consumer fires the request and waits for around fifteen seconds for the response, getting completely blocked at this period of waiting. There’s one big advantage in this case! You have a good excuse to grab a hot cup of coffee. :-)

Picture 1. The synchronous calling scenario

Now let’s start drawing the not so common scenarios, starting with the Asynchronous Web Services Calling using the pooling technique. We fires a request once in a while to check if the response is ready to be sent back. When it does, we call the method that provides the response. While the response is not ready, the client could be doing any other tasks. We will see the coding of this scenario soon in this article. Below, at Picture 2, we have the behaviour of this scenario.

Picture 2. The asynchronous polling calling scenario

At last, but probably the most interesting option, we have the web services asynchronous calling using a callback handler. Again, here the client have the opportunity to work on other tasks while waiting for the response to arrive. As the response comes through a callback, the client doesn’t have to do anything to trigger the receiving, only have to have an interface implemented, called AsyncHandler (JAX-WS 2.0), in order to the server have a point to deliver its response. The Picture 3 below show how this scenario works.

Picture 3. The asynchronous callback scenario

NOW, THE PROOF!

FIRST, ON THE SERVER SIDE…
THE WEB SERVICE IMPLEMENTATION AND “DEPLOYMENT”

On the server side there’s nothing new regarding the implementation, as we stated at the beginning of this article, the asynchronous communication is a feature of the JAX-WS web services clients. Here we are going to implement the server side...             Actually not exactly here...  ;-)

The whole article, source code and everything else, available at...

https://ualterazambuja.com/2016/04/23/web-services-asynchronous/

要查看或添加评论,请登录

Ualter Otoni Pereira的更多文章

  • AWS Terraform Snitcher

    AWS Terraform Snitcher

    Snitch (chivato in Spanish, “dedo-duro” in slang Portuguese), if you usually watch CNN, mainly political subjects…

  • KUBERNETES OPERATORS IN GO

    KUBERNETES OPERATORS IN GO

    An Operator is a software application written to run over Kubernetes, extending its functionalities to manage other…

  • Microservices: Quarkus vs. Spring Boot

    Microservices: Quarkus vs. Spring Boot

    In the era of containers (the “Docker Age“) Java still keeps alive, being struggling for it or not. Java has always…

    3 条评论
  • AWS ECS EC2, Cloud & Containers, Part II

    AWS ECS EC2, Cloud & Containers, Part II

    In this two-part article about Cloud and Containers working together, here in the second part we will try out the AWS…

    1 条评论
  • AWS ECS Fargate, Cloud & Containers, Part I

    AWS ECS Fargate, Cloud & Containers, Part I

    Let’s talk about Cloud and Containers working together, in this article we’ll see (in practice) how to run, scale and…

  • BUILDING A CRYPTOCURRENCY WITH BLOCKCHAIN

    BUILDING A CRYPTOCURRENCY WITH BLOCKCHAIN

    If you have a cryptocurrency, then you own something digitally, you have an asset, considered to be a coin because it…

    1 条评论
  • REACTIVE PROGRAMMING WITH SPRING WEBFLUX

    REACTIVE PROGRAMMING WITH SPRING WEBFLUX

    REACTIVE PROGRAMMING Recently we are frequently hearing about a new paradigm of coding that is gaining more and more…

  • OAUTH2 & GOOGLE API PART II

    OAUTH2 & GOOGLE API PART II

    In the first part of this article we have seen an introduction regard some basic concepts of this industry-standard…

  • OAUTH2 & GOOGLE API PART I

    OAUTH2 & GOOGLE API PART I

    OAuth 2.0, commonly pronounced “oh-auth”, is an industry-standard framework for *authentication and *authorization…

  • Messaging Request/Reply

    Messaging Request/Reply

    Messaging Integration Style Fire-and-Forget Pattern When we think integration using messaging style, what usually comes…

    1 条评论

社区洞察

其他会员也浏览了